1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
5 Test Twisted's doctest support.
8 from twisted.trial import itrial, runner, unittest, reporter
9 from twisted.trial.test import mockdoctest
12 class TestRunners(unittest.TestCase):
14 Tests for Twisted's doctest support.
19 Check that the id() of the doctests' case object contains the FQPN of
20 the actual tests. We need this because id() has weird behaviour w/
21 doctest in Python 2.3.
23 loader = runner.TestLoader()
24 suite = loader.loadDoctests(mockdoctest)
25 idPrefix = 'twisted.trial.test.mockdoctest.Counter'
26 for test in suite._tests:
27 self.assertIn(idPrefix, itrial.ITestCase(test).id())
30 def test_basicTrialIntegration(self):
32 L{loadDoctests} loads all of the doctests in the given module.
34 loader = runner.TestLoader()
35 suite = loader.loadDoctests(mockdoctest)
36 self.assertEqual(7, suite.countTestCases())
39 def _testRun(self, suite):
41 Run C{suite} and check the result.
43 result = reporter.TestResult()
45 self.assertEqual(5, result.successes)
46 # doctest reports failures as errors in 2.3
47 self.assertEqual(2, len(result.errors) + len(result.failures))
50 def test_expectedResults(self, count=1):
52 Trial can correctly run doctests with its xUnit test APIs.
54 suite = runner.TestLoader().loadDoctests(mockdoctest)
58 def test_repeatable(self):
60 Doctests should be runnable repeatably.
62 suite = runner.TestLoader().loadDoctests(mockdoctest)