twisted.trial.runner.TestLoader

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

72 Examples 7

Example 1

Project: mythbox
Source File: trial.py
View license
def _getLoader(config):
    loader = runner.TestLoader()
    if config['random']:
        randomer = random.Random()
        randomer.seed(config['random'])
        loader.sorter = lambda x : randomer.random()
        print 'Running tests shuffled with seed %d\n' % config['random']
    if not config['until-failure']:
        loader.suiteFactory = runner.DestructiveTestSuite
    return loader

Example 2

Project: mythbox
Source File: trial.py
View license
def _getLoader(config):
    loader = runner.TestLoader()
    if config['random']:
        randomer = random.Random()
        randomer.seed(config['random'])
        loader.sorter = lambda x : randomer.random()
        print 'Running tests shuffled with seed %d\n' % config['random']
    if not config['until-failure']:
        loader.suiteFactory = runner.DestructiveTestSuite
    return loader

Example 3

Project: mythbox
Source File: test_deferred.py
View license
    def test_classTimeout(self):
        loader = runner.TestLoader()
        suite = loader.loadClass(detests.TestClassTimeoutAttribute)
        result = reporter.TestResult()
        suite.run(result)
        self.failUnlessEqual(len(result.errors), 1)
        self._wasTimeout(result.errors[0][1])

Example 4

Project: mythbox
Source File: test_doctest.py
View license
    def test_id(self):
        """
        Check that the id() of the doctests' case object contains the FQPN of
        the actual tests. We need this because id() has weird behaviour w/
        doctest in Python 2.3.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        idPrefix = 'twisted.trial.test.mockdoctest.Counter'
        for test in suite._tests:
            self.assertIn(idPrefix, itrial.ITestCase(test).id())

Example 5

Project: mythbox
Source File: test_doctest.py
View license
    def test_basicTrialIntegration(self):
        """
        L{loadDoctests} loads all of the doctests in the given module.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        self.assertEqual(7, suite.countTestCases())

Example 6

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        self.loader = runner.TestLoader()
        self.topDir = self.mktemp()
        parent = os.path.join(self.topDir, "uberpackage")
        os.makedirs(parent)
        file(os.path.join(parent, "__init__.py"), "wb").close()
        packages.SysPathManglingTest.setUp(self, parent)
        self.mangleSysPath(self.oldPath + [self.topDir])

Example 7

Project: mythbox
Source File: test_runner.py
View license
    def test_runner_normal(self):
        self.parseOptions(['--temp-directory', self.mktemp(),
                           '--reporter', 'capturing',
                           'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)

Example 8

Project: mythbox
Source File: test_runner.py
View license
    def test_runner_debug(self):
        self.parseOptions(['--reporter', 'capturing',
                           '--debug', 'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        debugger = CapturingDebugger()
        def get_debugger():
            return debugger
        my_runner._getDebugger = get_debugger
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)
        self.assertEqual(['runcall'], debugger._calls)

Example 9

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

Project: mythbox
Source File: test_deferred.py
View license
    def test_classTimeout(self):
        loader = runner.TestLoader()
        suite = loader.loadClass(detests.TestClassTimeoutAttribute)
        result = reporter.TestResult()
        suite.run(result)
        self.failUnlessEqual(len(result.errors), 1)
        self._wasTimeout(result.errors[0][1])

Example 11

Project: mythbox
Source File: test_doctest.py
View license
    def test_id(self):
        """
        Check that the id() of the doctests' case object contains the FQPN of
        the actual tests. We need this because id() has weird behaviour w/
        doctest in Python 2.3.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        idPrefix = 'twisted.trial.test.mockdoctest.Counter'
        for test in suite._tests:
            self.assertIn(idPrefix, itrial.ITestCase(test).id())

Example 12

Project: mythbox
Source File: test_doctest.py
View license
    def test_basicTrialIntegration(self):
        """
        L{loadDoctests} loads all of the doctests in the given module.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        self.assertEqual(7, suite.countTestCases())

Example 13

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        self.loader = runner.TestLoader()
        self.topDir = self.mktemp()
        parent = os.path.join(self.topDir, "uberpackage")
        os.makedirs(parent)
        file(os.path.join(parent, "__init__.py"), "wb").close()
        packages.SysPathManglingTest.setUp(self, parent)
        self.mangleSysPath(self.oldPath + [self.topDir])

Example 14

Project: mythbox
Source File: test_runner.py
View license
    def test_runner_normal(self):
        self.parseOptions(['--temp-directory', self.mktemp(),
                           '--reporter', 'capturing',
                           'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)

Example 15

Project: mythbox
Source File: test_runner.py
View license
    def test_runner_debug(self):
        self.parseOptions(['--reporter', 'capturing',
                           '--debug', 'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        debugger = CapturingDebugger()
        def get_debugger():
            return debugger
        my_runner._getDebugger = get_debugger
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)
        self.assertEqual(['runcall'], debugger._calls)

Example 16

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

Project: SubliminalCollaborator
Source File: trial.py
View license
def _getLoader(config):
    loader = runner.TestLoader()
    if config['random']:
        randomer = random.Random()
        randomer.seed(config['random'])
        loader.sorter = lambda x : randomer.random()
        print 'Running tests shuffled with seed %d\n' % config['random']
    if not config['until-failure']:
        loader.suiteFactory = runner.DestructiveTestSuite
    return loader

Example 18

Project: SubliminalCollaborator
Source File: trial.py
View license
def _getLoader(config):
    loader = runner.TestLoader()
    if config['random']:
        randomer = random.Random()
        randomer.seed(config['random'])
        loader.sorter = lambda x : randomer.random()
        print 'Running tests shuffled with seed %d\n' % config['random']
    if not config['until-failure']:
        loader.suiteFactory = runner.DestructiveTestSuite
    return loader

Example 19

View license
    def test_classTimeout(self):
        loader = runner.TestLoader()
        suite = loader.loadClass(detests.TestClassTimeoutAttribute)
        result = reporter.TestResult()
        suite.run(result)
        self.assertEqual(len(result.errors), 1)
        self._wasTimeout(result.errors[0][1])

Example 20

View license
    def test_id(self):
        """
        Check that the id() of the doctests' case object contains the FQPN of
        the actual tests. We need this because id() has weird behaviour w/
        doctest in Python 2.3.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        idPrefix = 'twisted.trial.test.mockdoctest.Counter'
        for test in suite._tests:
            self.assertIn(idPrefix, itrial.ITestCase(test).id())

Example 21

View license
    def test_basicTrialIntegration(self):
        """
        L{loadDoctests} loads all of the doctests in the given module.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        self.assertEqual(7, suite.countTestCases())

Example 22

View license
    def setUp(self):
        self.loader = runner.TestLoader()
        self.topDir = self.mktemp()
        parent = os.path.join(self.topDir, "uberpackage")
        os.makedirs(parent)
        file(os.path.join(parent, "__init__.py"), "wb").close()
        packages.SysPathManglingTest.setUp(self, parent)
        self.mangleSysPath(self.oldPath + [self.topDir])

Example 23

View license
    def test_runner_normal(self):
        self.parseOptions(['--temp-directory', self.mktemp(),
                           '--reporter', 'capturing',
                           'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)

Example 24

View license
    def test_runner_debug(self):
        self.parseOptions(['--reporter', 'capturing',
                           '--debug', 'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        debugger = CapturingDebugger()
        def get_debugger():
            return debugger
        my_runner._getDebugger = get_debugger
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)
        self.assertEqual(['runcall'], debugger._calls)

Example 25

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

View license
    def loadSuite(self, suite):
        """
        Load tests from the given test case class and create a new reporter to
        use for running it.
        """
        self.loader = runner.TestLoader()
        self.suite = self.loader.loadClass(suite)
        self.reporter = reporter.TestResult()

Example 27

View license
    def test_classTimeout(self):
        loader = runner.TestLoader()
        suite = loader.loadClass(detests.TestClassTimeoutAttribute)
        result = reporter.TestResult()
        suite.run(result)
        self.assertEqual(len(result.errors), 1)
        self._wasTimeout(result.errors[0][1])

Example 28

View license
    def test_id(self):
        """
        Check that the id() of the doctests' case object contains the FQPN of
        the actual tests. We need this because id() has weird behaviour w/
        doctest in Python 2.3.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        idPrefix = 'twisted.trial.test.mockdoctest.Counter'
        for test in suite._tests:
            self.assertIn(idPrefix, itrial.ITestCase(test).id())

Example 29

View license
    def test_basicTrialIntegration(self):
        """
        L{loadDoctests} loads all of the doctests in the given module.
        """
        loader = runner.TestLoader()
        suite = loader.loadDoctests(mockdoctest)
        self.assertEqual(7, suite.countTestCases())

Example 30

View license
    def setUp(self):
        self.loader = runner.TestLoader()
        self.topDir = self.mktemp()
        parent = os.path.join(self.topDir, "uberpackage")
        os.makedirs(parent)
        file(os.path.join(parent, "__init__.py"), "wb").close()
        packages.SysPathManglingTest.setUp(self, parent)
        self.mangleSysPath(self.oldPath + [self.topDir])

Example 31

View license
    def test_runner_normal(self):
        self.parseOptions(['--temp-directory', self.mktemp(),
                           '--reporter', 'capturing',
                           'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)

Example 32

View license
    def test_runner_debug(self):
        self.parseOptions(['--reporter', 'capturing',
                           '--debug', 'twisted.trial.test.sample'])
        my_runner = self.getRunner()
        debugger = CapturingDebugger()
        def get_debugger():
            return debugger
        my_runner._getDebugger = get_debugger
        loader = runner.TestLoader()
        suite = loader.loadByName('twisted.trial.test.sample', True)
        result = my_runner.run(suite)
        self.assertEqual(self.standardReport, result._calls)
        self.assertEqual(['runcall'], debugger._calls)

Example 33

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

View license
    def loadSuite(self, suite):
        """
        Load tests from the given test case class and create a new reporter to
        use for running it.
        """
        self.loader = runner.TestLoader()
        self.suite = self.loader.loadClass(suite)
        self.reporter = reporter.TestResult()

Example 35

Project: mythbox
Source File: test_deferred.py
View license
    def _loadSuite(self, klass):
        loader = runner.TestLoader()
        r = reporter.TestResult()
        s = loader.loadClass(klass)
        return r, s

Example 36

Project: mythbox
Source File: test_deferred.py
View license
    def _loadSuite(self, klass):
        loader = runner.TestLoader()
        r = reporter.TestResult()
        s = loader.loadClass(klass)
        return r, s

Example 37

Project: mythbox
Source File: test_keyboard.py
View license
    def setUp(self):
        self.output = StringIO.StringIO()
        self.reporter = reporter.TestResult()
        self.loader = runner.TestLoader()

Example 38

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        packages.PackageTest.setUp(self)
        self.loader = runner.TestLoader()

Example 39

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        self.loader = runner.TestLoader()
        packages.SysPathManglingTest.setUp(self)

Example 40

Project: mythbox
Source File: test_runner.py
View license
    def test_shouldStop(self):
        """
        Test the C{shouldStop} management: raising a C{KeyboardInterrupt} must
        interrupt the suite.
        """
        called = []
        class MockTest(unittest.TestCase):
            def test_foo1(test):
                called.append(1)
            def test_foo2(test):
                raise KeyboardInterrupt()
            def test_foo3(test):
                called.append(2)
        result = reporter.TestResult()
        loader = runner.TestLoader()
        loader.suiteFactory = runner.DestructiveTestSuite
        suite = loader.loadClass(MockTest)
        self.assertEquals(called, [])
        suite.run(result)
        self.assertEquals(called, [1])
        # The last test shouldn't have been run
        self.assertEquals(suite.countTestCases(), 1)

Example 41

Project: mythbox
Source File: test_tests.py
View license
    def loadSuite(self, suite):
        self.loader = runner.TestLoader()
        self.suite = self.loader.loadClass(suite)
        self.reporter = reporter.TestResult()

Example 42

Project: mythbox
Source File: test_tests.py
View license
    def setUp(self):
        self.result = reporter.Reporter(StringIO.StringIO())
        self.loader = runner.TestLoader()

Example 43

Project: mythbox
Source File: test_tests.py
View license
    def setUp(self):
        self.reporter = reporter.Reporter()
        self.loader = runner.TestLoader()

Example 44

Project: mythbox
Source File: test_tests.py
View license
    def setUp(self):
        self.loader = runner.TestLoader()

Example 45

Project: mythbox
Source File: test_deferred.py
View license
    def _loadSuite(self, klass):
        loader = runner.TestLoader()
        r = reporter.TestResult()
        s = loader.loadClass(klass)
        return r, s

Example 46

Project: mythbox
Source File: test_deferred.py
View license
    def _loadSuite(self, klass):
        loader = runner.TestLoader()
        r = reporter.TestResult()
        s = loader.loadClass(klass)
        return r, s

Example 47

Project: mythbox
Source File: test_keyboard.py
View license
    def setUp(self):
        self.output = StringIO.StringIO()
        self.reporter = reporter.TestResult()
        self.loader = runner.TestLoader()

Example 48

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        packages.PackageTest.setUp(self)
        self.loader = runner.TestLoader()

Example 49

Project: mythbox
Source File: test_loader.py
View license
    def setUp(self):
        self.loader = runner.TestLoader()
        packages.SysPathManglingTest.setUp(self)

Example 50

Project: mythbox
Source File: test_runner.py
View license
    def test_shouldStop(self):
        """
        Test the C{shouldStop} management: raising a C{KeyboardInterrupt} must
        interrupt the suite.
        """
        called = []
        class MockTest(unittest.TestCase):
            def test_foo1(test):
                called.append(1)
            def test_foo2(test):
                raise KeyboardInterrupt()
            def test_foo3(test):
                called.append(2)
        result = reporter.TestResult()
        loader = runner.TestLoader()
        loader.suiteFactory = runner.DestructiveTestSuite
        suite = loader.loadClass(MockTest)
        self.assertEquals(called, [])
        suite.run(result)
        self.assertEquals(called, [1])
        # The last test shouldn't have been run
        self.assertEquals(suite.countTestCases(), 1)