~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/twisted/trial/test/test_doctest.py

  • Committer: Thomas Hervé
  • Date: 2009-07-08 13:52:04 UTC
  • Revision ID: thomas@canonical.com-20090708135204-df5eesrthifpylf8
Remove twisted copy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3
 
# See LICENSE for details.
4
 
 
5
 
"""test twisted's doctest support
6
 
"""
7
 
 
8
 
from twisted.trial import runner, unittest, reporter
9
 
from twisted.trial.test import mockdoctest
10
 
 
11
 
 
12
 
class TestRunners(unittest.TestCase):
13
 
    def test_id(self):
14
 
        """Check that the id() of the doctests' case object contains the FQPN
15
 
        of the actual tests.  We need this because id() has weird behaviour w/
16
 
        doctest in Python 2.3.
17
 
        """
18
 
        loader = runner.TestLoader()
19
 
        suite = loader.loadDoctests(mockdoctest)
20
 
        idPrefix = 'twisted.trial.test.mockdoctest.Counter'
21
 
        for test in suite._tests:
22
 
            self.assertIn(idPrefix, test.id())
23
 
    
24
 
    def test_correctCount(self):
25
 
        suite = runner.DocTestSuite(mockdoctest)
26
 
        self.assertEqual(7, suite.countTestCases())
27
 
 
28
 
    def test_basicTrialIntegration(self):
29
 
        loader = runner.TestLoader()
30
 
        suite = loader.loadDoctests(mockdoctest)
31
 
        self.assertEqual(7, suite.countTestCases())
32
 
 
33
 
    def test_expectedResults(self):
34
 
        suite = runner.DocTestSuite(mockdoctest)
35
 
        result = reporter.TestResult()
36
 
        suite.run(result)
37
 
        self.assertEqual(5, len(result.successes))
38
 
        # doctest reports failures as errors in 2.3
39
 
        self.assertEqual(2, len(result.errors) + len(result.failures))
40