def test_iterateNestedTestSuite(self):
     """
     L{_iterateTests} returns tests that are in nested test suites.
     """
     test = self.TestCase()
     suite = runner.TestSuite([runner.TestSuite([test])])
     self.assertEqual([test], list(_iterateTests(suite)))
 def test_iterateIsLeftToRightDepthFirst(self):
     """
     L{_iterateTests} returns tests in left-to-right, depth-first order.
     """
     test = self.TestCase()
     suite = runner.TestSuite([runner.TestSuite([test]), self])
     self.assertEqual([test, self], list(_iterateTests(suite)))
Example #3
0
    def makeTestFixtures(self):
        class MockTest(unittest.TestCase):
            def test_foo(test):
                self.log.append('test_foo')

        self.test = MockTest('test_foo')
        self.suite = runner.TestSuite()
Example #4
0
 def assertSuitesEqual(self, test1, names):
     loader = runner.TestLoader()
     names1 = testNames(test1)
     names2 = testNames(runner.TestSuite(map(loader.loadByName, names)))
     names1.sort()
     names2.sort()
     self.assertEqual(names1, names2)
Example #5
0
 def test_empty(self):
     """
     If there are no tests, the reporter should not receive any events to
     report.
     """
     result = self.runner.run(runner.TestSuite())
     self.assertEqual(result._calls, [])
 def test_iterateSingletonTestSuite(self):
     """
     L{_iterateTests} on a test suite that contains a single test case
     returns a list containing that test case.
     """
     test = self.TestCase()
     suite = runner.TestSuite([test])
     self.assertEqual([test], list(_iterateTests(suite)))
Example #7
0
 def test_loadDifferentNames(self):
     """
     Check that loadByNames loads all the names that it is given
     """
     modules = ['goodpackage', 'package.test_module']
     suite1 = self.loader.loadByNames(modules)
     suite2 = runner.TestSuite(map(self.loader.loadByName, modules))
     self.assertSuitesEqual(suite1, suite2)
Example #8
0
def test_suite():
    ts = runner.TestSuite()
    ts.name = "bit.bot.http.doctests"
    ts.addTest(
        doctest.DocFileSuite("../README.rst",
                             setUp=setUp,
                             optionflags=doctest.ELLIPSIS
                             | doctest.NORMALIZE_WHITESPACE))
    return ts
Example #9
0
def _getSuite(config):
    loader = _getLoader(config)
    suite = runner.TestSuite()
    recurse = not config['no-recurse']
    for test in config['tests']:
        if isinstance(test, str):
            suite.addTest(loader.loadByName(test, recurse))
        else:
            suite.addTest(loader.loadAnything(test, recurse))
    return suite
Example #10
0
 def test_loadInheritedMethods(self):
     """
     Check that test methods names which are inherited from are all
     loaded rather than just one.
     """
     methods = ['inheritancepackage.test_x.A.test_foo',
                'inheritancepackage.test_x.B.test_foo']
     suite1 = self.loader.loadByNames(methods)
     suite2 = runner.TestSuite(map(self.loader.loadByName, methods))
     self.assertSuitesEqual(suite1, suite2)
Example #11
0
 def test_loadByNamesPreservesOrder(self):
     """
     L{TestLoader.loadByNames} preserves the order of tests provided to it.
     """
     modules = [
         "inheritancepackage.test_x.A.test_foo",
         "twisted.trial.test.sample", "goodpackage",
         "twisted.trial.test.test_log", "twisted.trial.test.sample.FooTest",
         "package.test_module"
     ]
     suite1 = self.loader.loadByNames(modules)
     suite2 = runner.TestSuite(map(self.loader.loadByName, modules))
     self.assertEqual(testNames(suite1), testNames(suite2))
def trialMain(testClass):
	from twisted.trial import runner
	from twisted.scripts import trial as script
	config = script.Options()
	config.parseOptions()
	trialRunner = script._makeRunner(config)
	if len(sys.argv)>1:
		suite = runner.TestSuite()
		for t in sys.argv[1:]:
			suite.addTest(testClass(t))
	else:
		sys.argv.append(sys.argv[0])
		config.parseOptions()
		suite = script._getSuite(config)
	trialRunner.run(suite)
Example #13
0
 def test_collectCalledWhenTearDownClass(self):
     """test gc.collect is called after tearDownClasss"""
     tests = [
         TestGarbageCollection.ClassTest('test_1'),
         TestGarbageCollection.ClassTest('test_2')
     ]
     for t in tests:
         t.forceGarbageCollection = True
     test = runner.TestSuite(tests)
     result = reporter.TestResult()
     test.run(result)
     # check that collect gets called after individual tests, and
     # after tearDownClass
     self.failUnlessEqual(self._collectCalled, [
         'collect', 'test1', 'collect', 'collect', 'test2', 'tearDownClass',
         'collect'
     ])
def test_suite():
    ts = runner.TestSuite()
    ts.name = "MyCustomSuite"
    return ts
Example #15
0
 def setUp(self):
     self.config = trial.Options()
     self.log = []
     self.patch(gc, 'collect', self.collect)
     test = pyunit.FunctionTestCase(self.simpleTest)
     self.test = runner.TestSuite([test, test])
Example #16
0
def testSuite():
    ts = runner.TestSuite()
    ts.name = "testSuite"
    return ts
Example #17
0
def GetTestSuite():
    suite = runner.TestSuite(PokerDatabaseTestCase)
    suite.addTest(unittest.makeSuite(PokerDatabaseTestCase))
    return suite