def test_visitNestedSuite(self): """ Test that C{visit} recurses through suites. """ tests = [ TestTestVisitor('test_visitCase'), TestTestVisitor('test_visitSuite') ] testSuite = TestSuite([TestSuite([test]) for test in tests]) testSuite.visit(self.visitor) self.assertEqual(self.visitor.calls, tests)
def assertSuitesEqual(self, test1, names): loader = TestLoader() names1 = testNames(test1) names2 = testNames(TestSuite(map(loader.loadByName, names))) names1.sort() names2.sort() self.assertEqual(names1, names2)
def test_visitPyunitCase(self): """ Test that a stdlib test case in a suite gets visited. """ class PyunitCase(pyunit.TestCase): def test_foo(self): pass test = PyunitCase('test_foo') TestSuite([test]).visit(self.visitor) self.assertEqual(self.visitor.calls, [test])
def test_visitSuite(self): """ Test that C{visit} hits all tests in a suite. """ tests = [ TestTestVisitor('test_visitCase'), TestTestVisitor('test_visitSuite') ] testSuite = TestSuite(tests) testSuite.visit(self.visitor) self.assertEqual(self.visitor.calls, tests)
def test_preserveArgumentOrder(self): """ Multiple tests passed on the command line are not reordered. """ tests = [ "twisted.trial.test.test_tests", "twisted.trial.test.test_assertions", "twisted.trial.test.test_deferred", ] self.config.parseOptions(tests) suite = trial._getSuite(self.config) names = testNames(suite) expectedSuite = TestSuite(map(self.loader.loadByName, tests)) expectedNames = testNames(expectedSuite) self.assertEqual(names, expectedNames)
def setUp(self): self.config = trial.Options() self.log = [] self.patch(gc, 'collect', self.collect) test = pyunit.FunctionTestCase(self.simpleTest) self.test = TestSuite([test, test])
def test_visitEmptySuite(self): """ Test that C{visit} on an empty suite hits nothing. """ TestSuite().visit(self.visitor) self.assertEqual(self.visitor.calls, [])