twisted.trial.runner.TestSuite

Here are the examples of the python api twisted.trial.runner.TestSuite taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

66 Examples 7

Example 1

Project: mythbox
Source File: test_loader.py
View license
    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 2

Project: mythbox
Source File: test_runner.py
View license
    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, [])

Example 3

Project: mythbox
Source File: test_runner.py
View license
    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

Project: mythbox
Source File: test_script.py
View license
    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 5

Project: mythbox
Source File: test_script.py
View license
    def test_untilFailureSuite(self):
        """
        The C{until-failure} configuration uses the L{runner.TestSuite} to keep
        instances alive across runs.
        """
        self.config['until-failure'] = True
        loader = trial._getLoader(self.config)
        self.assertEquals(loader.suiteFactory, runner.TestSuite)

Example 6

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateSingletonTestSuite(self):
        """
        L{_iterateTests} on a test suite that contains a single test case
        returns a list containing that test case.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([test])
        self.assertEqual([test], list(unittest._iterateTests(suite)))

Example 7

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateNestedTestSuite(self):
        """
        L{_iterateTests} returns tests that are in nested test suites.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([runner.TestSuite([test])])
        self.assertEqual([test], list(unittest._iterateTests(suite)))

Example 8

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateIsLeftToRightDepthFirst(self):
        """
        L{_iterateTests} returns tests in left-to-right, depth-first order.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([runner.TestSuite([test]), self])
        self.assertEqual([test, self], list(unittest._iterateTests(suite)))

Example 9

Project: mythbox
Source File: test_test_visitor.py
View license
    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)

Example 10

Project: mythbox
Source File: test_test_visitor.py
View license
    def test_visitEmptySuite(self):
        """
        Test that C{visit} on an empty suite hits nothing.
        """
        TestSuite().visit(self.visitor)
        self.assertEqual(self.visitor.calls, [])

Example 11

Project: mythbox
Source File: test_test_visitor.py
View license
    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)

Example 12

Project: mythbox
Source File: test_test_visitor.py
View license
    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(
            [call.id() for call in self.visitor.calls], [test.id()])

Example 13

Project: mythbox
Source File: test_loader.py
View license
    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 14

Project: mythbox
Source File: test_runner.py
View license
    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, [])

Example 15

Project: mythbox
Source File: test_runner.py
View license
    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 16

Project: mythbox
Source File: test_script.py
View license
    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 17

Project: mythbox
Source File: test_script.py
View license
    def test_untilFailureSuite(self):
        """
        The C{until-failure} configuration uses the L{runner.TestSuite} to keep
        instances alive across runs.
        """
        self.config['until-failure'] = True
        loader = trial._getLoader(self.config)
        self.assertEquals(loader.suiteFactory, runner.TestSuite)

Example 18

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateSingletonTestSuite(self):
        """
        L{_iterateTests} on a test suite that contains a single test case
        returns a list containing that test case.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([test])
        self.assertEqual([test], list(unittest._iterateTests(suite)))

Example 19

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateNestedTestSuite(self):
        """
        L{_iterateTests} returns tests that are in nested test suites.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([runner.TestSuite([test])])
        self.assertEqual([test], list(unittest._iterateTests(suite)))

Example 20

Project: mythbox
Source File: test_tests.py
View license
    def test_iterateIsLeftToRightDepthFirst(self):
        """
        L{_iterateTests} returns tests in left-to-right, depth-first order.
        """
        test = unittest.TestCase()
        suite = runner.TestSuite([runner.TestSuite([test]), self])
        self.assertEqual([test, self], list(unittest._iterateTests(suite)))

Example 21

Project: mythbox
Source File: test_test_visitor.py
View license
    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)

Example 22

Project: mythbox
Source File: test_test_visitor.py
View license
    def test_visitEmptySuite(self):
        """
        Test that C{visit} on an empty suite hits nothing.
        """
        TestSuite().visit(self.visitor)
        self.assertEqual(self.visitor.calls, [])

Example 23

Project: mythbox
Source File: test_test_visitor.py
View license
    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)

Example 24

Project: mythbox
Source File: test_test_visitor.py
View license
    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(
            [call.id() for call in self.visitor.calls], [test.id()])

Example 25

View license
    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 26

View license
    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 27

View license
    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, [])

Example 28

View license
    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 29

View license
    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 30

View license
    def test_untilFailureSuite(self):
        """
        The C{until-failure} configuration uses the L{runner.TestSuite} to keep
        instances alive across runs.
        """
        self.config['until-failure'] = True
        loader = trial._getLoader(self.config)
        self.assertEqual(loader.suiteFactory, runner.TestSuite)

Example 31

View license
    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(unittest._iterateTests(suite)))

Example 32

View license
    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(unittest._iterateTests(suite)))

Example 33

View license
    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(unittest._iterateTests(suite)))

Example 34

View license
    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)

Example 35

View license
    def test_visitEmptySuite(self):
        """
        Test that C{visit} on an empty suite hits nothing.
        """
        TestSuite().visit(self.visitor)
        self.assertEqual(self.visitor.calls, [])

Example 36

View license
    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)

Example 37

View license
    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(
            [call.id() for call in self.visitor.calls], [test.id()])

Example 38

View license
    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 39

View license
    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 40

View license
    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, [])

Example 41

View license
    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 42

View license
    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 43

View license
    def test_untilFailureSuite(self):
        """
        The C{until-failure} configuration uses the L{runner.TestSuite} to keep
        instances alive across runs.
        """
        self.config['until-failure'] = True
        loader = trial._getLoader(self.config)
        self.assertEqual(loader.suiteFactory, runner.TestSuite)

Example 44

View license
    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(unittest._iterateTests(suite)))

Example 45

View license
    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(unittest._iterateTests(suite)))

Example 46

View license
    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(unittest._iterateTests(suite)))

Example 47

View license
    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)

Example 48

View license
    def test_visitEmptySuite(self):
        """
        Test that C{visit} on an empty suite hits nothing.
        """
        TestSuite().visit(self.visitor)
        self.assertEqual(self.visitor.calls, [])

Example 49

View license
    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)

Example 50

View license
    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(
            [call.id() for call in self.visitor.calls], [test.id()])