def getSuites(): suites = [doctestSuite] loader = TestLoader() for startDir in searchDirs: for testFile in findTests(startDir, skipFiles): modBase = os.path.splitext(testFile)[0] name = modBase.replace(os.path.sep, '.') # import the testFile as a module mod = importModule(name) # iterate through module objects, checking for TestCases for objName in dir(mod): if not objName.endswith('TestCase'): continue obj = getattr(mod, objName) if not issubclass(obj, TestCase): continue # create a suite from any test cases suite = loader.loadTestsFromTestCase(obj) # append to suites list suites.append(suite) return suites
import unittest import doctest from rtfng.utils import importModule # to add a new module to the test runner, simply include is in the list below: modules = [ 'rtfng.parser.grammar', 'rtfng.parser.base', ] suite = unittest.TestSuite() for modname in modules: mod = importModule(modname) suite.addTest(doctest.DocTestSuite(mod)) if __name__ == '__main__': runner = unittest.TextTestRunner(verbosity=2) runner.run(suite)
pending = base + ['pending'] baseDir = os.path.join(*base) pendingDir = os.path.join(*pending) doneList = [] requestedList = sys.argv[1:] if requestedList: print('Only writing these methods: %s' % ', '.join(requestedList)) # iterate through the test files for startDir in searchDirs: for testFile in findTests(startDir, skipFiles): modBase = os.path.splitext(testFile)[0] name = modBase.replace(os.path.sep, '.') # import the testFile as a module mod = importModule(name) # iterate through module objects, checking for TestCases for objName in dir(mod): if not objName.endswith('TestCase'): continue obj = getattr(mod, objName) if not issubclass(obj, TestCase): continue # iterate through the TestCase attrs, looking for make_* # methods for attrName in dir(obj): if attrName.startswith('make_'): # Make sure this is not a duplicate. if attrName in doneList: raise Exception('Duplicate test method found: %s' %
pending = base + ['pending'] baseDir = os.path.join(*base) pendingDir = os.path.join(*pending) doneList = [] requestedList = sys.argv[1:] if requestedList: print 'Only writing these methods: %s' % ', '.join(requestedList) # iterate through the test files for startDir in searchDirs: for testFile in findTests(startDir, skipFiles): modBase = os.path.splitext(testFile)[0] name = modBase.replace(os.path.sep, '.') # import the testFile as a module mod = importModule(name) # iterate through module objects, checking for TestCases for objName in dir(mod): if not objName.endswith('TestCase'): continue obj = getattr(mod, objName) if not issubclass(obj, TestCase): continue # iterate through the TestCase attrs, looking for make_* # methods for attrName in dir(obj): if attrName.startswith('make_'): # Make sure this is not a duplicate. if attrName in doneList: raise Exception('Duplicate test method found: %s' % attrName)