Add E2E tests

This commit is contained in:
Thomas Lauf 2023-01-02 22:02:14 +01:00
parent 487dfed981
commit 29479d064e
13 changed files with 2204 additions and 216 deletions

36
test/basetest/meta.py Normal file
View file

@ -0,0 +1,36 @@
from __future__ import print_function, division
class MetaTest(type):
"""Helper metaclass to simplify dynamic test creation
Creates test_methods in the TestCase class dynamically named after the
arguments used.
"""
@staticmethod
def make_function(classname, *args, **kwargs):
def test(self):
# ### Body of the usual test_testcase ### #
# Override and redefine this method #
pass
# Title of test in report
test.__doc__ = "{0}".format(args[0])
return test
def __new__(meta, classname, bases, dct):
tests = dct.get("TESTS")
kwargs = dct.get("EXTRA", {})
for i, args in enumerate(tests):
func = meta.make_function(classname, *args, **kwargs)
# Rename the function after a unique identifier
# Name of function must start with test_ to be ran by unittest
func.__name__ = "test_{0}".format(i)
# Attach the new test to the testclass
dct[func.__name__] = func
return super(MetaTest, meta).__new__(meta, classname, bases, dct)