git.schokokeks.org
Repositories
Help
Report an Issue
freewvs.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
2fd68de
Branches
Tags
master
v0.1.1
v0.1.2
v0.1.3
v0.1.4
freewvs.git
tests
test_freewvs_testdata.py
make test var names more generic
Hanno Böck
commited
2fd68de
at 2020-05-03 13:26:39
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("RUN_ONLINETESTS"), "Not running online tests") def test_freewvs_testdata(self): tmp = tempfile.mkdtemp(prefix="testdata") if os.environ.get("TESTDATA_REPOSITORY"): os.symlink(os.environ.get("TESTDATA_REPOSITORY"), tmp + "/testdata") else: subprocess.run(["git", "clone", "--depth=1", TESTDATA_REPO, tmp + "/testdata"], check=True) for tdir in glob.glob(tmp + "/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))) self.assertEqual(refclean, fwclean, msg="Output in %s does not match" % bdir) if __name__ == '__main__': unittest.main()