git.schokokeks.org
Repositories
Help
Report an Issue
freewvs.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
0aeada3
Branches
Tags
master
v0.1.1
v0.1.2
v0.1.3
v0.1.4
freewvs.git
tests
test_freewvs_testdata.py
avoid some pylint warnings
Hanno Böck
commited
0aeada3
at 2019-12-14 09:46:03
test_freewvs_testdata.py
Blame
History
Raw
import unittest import subprocess import glob import os import tempfile import shutil import re import difflib TESTDATA_REPO = "https://github.com/schokokeksorg/freewvs-testdata" class TestFreewvsData(unittest.TestCase): @unittest.skipUnless(os.environ.get("FREEWVS_ONLINETESTS"), "Not running online tests") def test_freewvs_testdata(self): tmp = tempfile.mkdtemp(prefix="freewvs-testdata") if os.environ.get("FREEWVS_TESTDATA_REPOSITORY"): os.symlink(os.environ.get("FREEWVS_TESTDATA_REPOSITORY"), tmp + "/freewvs-testdata") else: subprocess.run(["git", "clone", "--depth=1", TESTDATA_REPO, tmp + "/freewvs-testdata"], check=True) for tdir in glob.glob(tmp + "/freewvs-testdata/webapps/*"): bdir = os.path.basename(tdir) for tarball in glob.glob(tdir + "/dist/*"): shutil.unpack_archive(tarball, "%s/%s/%s-src" % (tmp, bdir, os.path.basename(tarball))) fwrun = subprocess.run(["./freewvs", "-a", tmp + "/" + bdir], stdout=subprocess.PIPE, check=True) fwdata = re.sub(tmp, "[dir]", fwrun.stdout.decode("utf-8")) fwclean = re.sub(r' \(.* ', " ", fwdata) f = open(tdir + "/refdata-a.txt") refdata = f.read() f.close() refclean = re.sub(r' \(.* ', " ", refdata) fwclean = sorted(fwclean.split("\n")) refclean = sorted(refclean.split("\n")) if refclean != fwclean: print("\n".join(difflib.ndiff(refclean, fwclean))) raise Exception("Output in %s does not match" % bdir) if __name__ == '__main__': unittest.main()