HEXDUMP_FILTER = bytearray([x if ((len(repr(chr(x))) == 3) and (x < 127)) else ord('.') for x in range(256)])
+def DynamicTestCase(cls):
+ cls.setUpDynamicTestCases()
+ return cls
class TestCase(unittest.TestCase):
"""A Samba test case."""
+ @classmethod
+ def generate_dynamic_test(cls, fnname, suffix, *args):
+ """
+ fnname is something like "test_dynamic_sum"
+ suffix is something like "1plus2"
+ argstr could be (1, 2)
+
+ This would generate a test case called
+ "test_dynamic_sum_1plus2(self)" that
+ calls
+ self._test_dynamic_sum_with_args(1, 2)
+ """
+ def fn(self):
+ getattr(self, "_%s_with_args" % fnname)(*args)
+ setattr(cls, "%s_%s" % (fnname, suffix), fn)
+
+ @classmethod
+ def setUpDynamicTestCases(cls):
+ """This can be implemented in order to call cls.generate_dynamic_test()
+ In order to implement autogenerated testcase permutations.
+ """
+ msg = "%s needs setUpDynamicTestCases() if @DynamicTestCase is used!" % (cls)
+ raise Exception(msg)
+
def setUp(self):
super(TestCase, self).setUp()
test_debug_level = os.getenv("TEST_DEBUG_LEVEL")