mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
Add a few tests for pydoc.
This is a modified version of a patch proposed by Humberto Diogenes in the discussion of issue1883. I will merge manually this change into the py3k branch: the tests must be adapted.
This commit is contained in:
parent
48ebc264f8
commit
747720540c
2 changed files with 33 additions and 1 deletions
33
Lib/test/test_pydoc.py
Normal file
33
Lib/test/test_pydoc.py
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
from test import test_support
|
||||||
|
import unittest
|
||||||
|
import pydoc
|
||||||
|
|
||||||
|
class TestDescriptions(unittest.TestCase):
|
||||||
|
def test_module(self):
|
||||||
|
# Check that pydocfodder module can be described
|
||||||
|
import pydocfodder
|
||||||
|
doc = pydoc.render_doc(pydocfodder)
|
||||||
|
assert "pydocfodder" in doc
|
||||||
|
|
||||||
|
def test_classic_class(self):
|
||||||
|
class C: "Classic class"
|
||||||
|
c = C()
|
||||||
|
self.failUnlessEqual(pydoc.describe(C), 'class C')
|
||||||
|
self.failUnlessEqual(pydoc.describe(c), 'instance of C')
|
||||||
|
self.failUnless('instance of C in module test.test_pydoc'
|
||||||
|
in pydoc.render_doc(c))
|
||||||
|
|
||||||
|
def test_class(self):
|
||||||
|
class C(object): "New-style class"
|
||||||
|
c = C()
|
||||||
|
|
||||||
|
self.failUnlessEqual(pydoc.describe(C), 'class C')
|
||||||
|
self.failUnlessEqual(pydoc.describe(c), 'C')
|
||||||
|
self.failUnless('C in module test.test_pydoc object'
|
||||||
|
in pydoc.render_doc(c))
|
||||||
|
|
||||||
|
def test_main():
|
||||||
|
test_support.run_unittest(TestDescriptions)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
|
@ -90,7 +90,6 @@ class TestUntestedModules(unittest.TestCase):
|
||||||
import posixfile
|
import posixfile
|
||||||
import pstats
|
import pstats
|
||||||
import py_compile
|
import py_compile
|
||||||
import pydoc
|
|
||||||
import rexec
|
import rexec
|
||||||
import rlcompleter
|
import rlcompleter
|
||||||
import sched
|
import sched
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue