Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / lib / python2.7 / dist-packages / twisted / trial / test / | server ip : 104.21.89.46 your ip : 172.69.58.250 H O M E |
Filename | /usr/lib/python2.7/dist-packages/twisted/trial/test/test_doctest.py |
Size | 1.67 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:56 |
Last modified | 03-Apr-2013 02:27 |
Last accessed | 07-Jul-2025 12:32 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Test Twisted's doctest support.
"""
from twisted.trial import itrial, runner, unittest, reporter
from twisted.trial.test import mockdoctest
class TestRunners(unittest.SynchronousTestCase):
"""
Tests for Twisted's doctest support.
"""
def test_id(self):
"""
Check that the id() of the doctests' case object contains the FQPN of
the actual tests.
"""
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())
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())
def _testRun(self, suite):
"""
Run C{suite} and check the result.
"""
result = reporter.TestResult()
suite.run(result)
self.assertEqual(5, result.successes)
self.assertEqual(2, len(result.failures))
def test_expectedResults(self, count=1):
"""
Trial can correctly run doctests with its xUnit test APIs.
"""
suite = runner.TestLoader().loadDoctests(mockdoctest)
self._testRun(suite)
def test_repeatable(self):
"""
Doctests should be runnable repeatably.
"""
suite = runner.TestLoader().loadDoctests(mockdoctest)
self._testRun(suite)
self._testRun(suite)
# See LICENSE for details.
"""
Test Twisted's doctest support.
"""
from twisted.trial import itrial, runner, unittest, reporter
from twisted.trial.test import mockdoctest
class TestRunners(unittest.SynchronousTestCase):
"""
Tests for Twisted's doctest support.
"""
def test_id(self):
"""
Check that the id() of the doctests' case object contains the FQPN of
the actual tests.
"""
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())
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())
def _testRun(self, suite):
"""
Run C{suite} and check the result.
"""
result = reporter.TestResult()
suite.run(result)
self.assertEqual(5, result.successes)
self.assertEqual(2, len(result.failures))
def test_expectedResults(self, count=1):
"""
Trial can correctly run doctests with its xUnit test APIs.
"""
suite = runner.TestLoader().loadDoctests(mockdoctest)
self._testRun(suite)
def test_repeatable(self):
"""
Doctests should be runnable repeatably.
"""
suite = runner.TestLoader().loadDoctests(mockdoctest)
self._testRun(suite)
self._testRun(suite)