1 import unittest
2 import types
3
5 cases = []
6
9
10 generateCases = classmethod(generateCases)
11
13 tests = []
14 for case in cls.generateCases():
15 if isinstance(case, tuple):
16 test = cls(*case)
17 elif isinstance(case, dict):
18 test = cls(**case)
19 else:
20 test = cls(case)
21 tests.append(test)
22 return tests
23
24 loadTests = classmethod(loadTests)
25
27 unittest.TestCase.__init__(self, 'runOneTest')
28 self.description = description
29
31 return '%s for %s' % (self.__class__.__name__, self.description)
32
34 loader = unittest.defaultTestLoader
35 this_module = __import__(module_name, {}, {}, [None])
36
37 tests = []
38 for name in dir(this_module):
39 obj = getattr(this_module, name)
40 if (isinstance(obj, (type, types.ClassType)) and
41 issubclass(obj, unittest.TestCase)):
42 if hasattr(obj, 'loadTests'):
43 tests.extend(obj.loadTests())
44 else:
45 tests.append(loader.loadTestsFromTestCase(obj))
46
47 return unittest.TestSuite(tests)
48