getting file size for all dict files to be downloaded. coming to be 400mb or so.
[worddb.git] / libs / openid / test / datadriven.py
blob2dbcfd0d9e02882a3db6cc6ee3b91cac493e02b1
1 import unittest
2 import types
4 class DataDrivenTestCase(unittest.TestCase):
5 cases = []
7 def generateCases(cls):
8 return cls.cases
10 generateCases = classmethod(generateCases)
12 def loadTests(cls):
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
24 loadTests = classmethod(loadTests)
26 def __init__(self, description):
27 unittest.TestCase.__init__(self, 'runOneTest')
28 self.description = description
30 def shortDescription(self):
31 return '%s for %s' % (self.__class__.__name__, self.description)
33 def loadTests(module_name):
34 loader = unittest.defaultTestLoader
35 this_module = __import__(module_name, {}, {}, [None])
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))
47 return unittest.TestSuite(tests)