def testTwoCasesInGraph(self): res1 = self.makeResource() res2 = self.makeResource() set1 = frozenset([res1, res2]) set2 = frozenset([res2]) no_resources = frozenset() suite = testresources.OptimisingTestSuite() graph = suite._getGraph([no_resources, set1, set2]) self.assertEqual( { no_resources: { set1: 2, set2: 1 }, set1: { no_resources: 2, set2: 1 }, set2: { no_resources: 1, set1: 1 } }, graph)
def test_suite(): packages = [ 'arguments', 'commands', 'repository', 'ui', ] names = [ 'arguments', 'commands', 'matchers', 'monkeypatch', 'repository', 'results', 'setup', 'stubpackage', 'testcommand', 'testr', 'ui', ] module_names = ['testrepository.tests.test_' + name for name in names] loader = unittest.TestLoader() suite = loader.loadTestsFromNames(module_names) result = testresources.OptimisingTestSuite() result.addTests(generate_scenarios(suite)) for pkgname in packages: pkg = __import__('testrepository.tests.' + pkgname, globals(), locals(), ['test_suite']) result.addTests(generate_scenarios(pkg.test_suite())) return result
def load_tests(loader, found_tests, pattern): result = testresources.OptimisingTestSuite() result.addTests(found_tests) pkg_tests = loader.discover(start_dir=this_dir, pattern=pattern) result.addTests(testscenarios.generate_scenarios(pkg_tests)) return result
def load_tests(loader, standard_tests, pattern): # top level directory cached on loader instance this_dir = os.path.dirname(__file__) package_tests = loader.discover(start_dir=this_dir, pattern=pattern) result = testresources.OptimisingTestSuite() result.addTests(generate_scenarios(standard_tests)) result.addTests(generate_scenarios(package_tests)) return result
def module_load_tests(loader, found_tests, pattern): """Apply OptimisingTestSuite on a per-module basis. FIXME(zzzeek): oslo.db provides this but the contract that "pattern" should be None no longer seems to behave as it used to at the module level, so this function needs to be added in this form. """ result = testresources.OptimisingTestSuite() found_tests = testscenarios.load_tests_apply_scenarios( loader, found_tests, pattern) result.addTest(found_tests) return result
def load_tests(loader, found_tests, pattern): # pattern is None if the directive is placed within # a test module directly, as well as within certain test # discovery patterns if pattern is not None: pkg_tests = loader.discover(start_dir=this_dir, pattern=pattern) result = testresources.OptimisingTestSuite() found_tests = testscenarios.load_tests_apply_scenarios( loader, found_tests, pattern) result.addTest(found_tests) if pattern is not None: result.addTest(pkg_tests) return result
def load_tests(loader, tests, pattern): return testresources.OptimisingTestSuite(tests)
def setUp(self): super(TestOptimisingTestSuite, self).setUp() self.optimising_suite = testresources.OptimisingTestSuite()
def sortTests(self, tests): suite = testresources.OptimisingTestSuite() suite.addTests(tests) suite.sortTests() return suite._tests
def testSingletonGraph(self): resource = self.makeResource() suite = testresources.OptimisingTestSuite() graph = suite._getGraph([frozenset()]) self.assertEqual({frozenset(): {}}, graph)
def testEmptyGraph(self): suite = testresources.OptimisingTestSuite() graph = suite._getGraph([]) self.assertEqual({}, graph)
def setUp(self): super(TestCostOfSwitching, self).setUp() self.suite = testresources.OptimisingTestSuite()
def load_tests(loader, found_tests, pattern): result = testresources.OptimisingTestSuite() result.addTests(testscenarios.generate_scenarios(found_tests)) return result
def load_tests(loader, tests, pattern): scenarios = testscenarios.generate_scenarios(tests) return testresources.OptimisingTestSuite(scenarios)
def load_tests(loader, standard_tests, pattern): this_dir = os.path.dirname(__file__) package_tests = loader.discover(start_dir=this_dir, pattern=pattern) standard_tests.addTests(package_tests) return testresources.OptimisingTestSuite(standard_tests)
def load_tests(loader, standard_tests, pattern): # top level directory cached on loader instance suite = testresources.OptimisingTestSuite() tests = loader.loadTestsFromTestCase(SystemTests) suite.addTests(tests) return suite