summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-24 20:22:26 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-24 20:22:26 (GMT)
commit747720540ccbf0c567c80d19bb4d7167043ae2be (patch)
tree2c62eb42bedaef34e2b52ee2759f9678c8a26359 /Lib/test
parent48ebc264f8a92824f3872049a581f0e45d1a5009 (diff)
downloadcpython-747720540ccbf0c567c80d19bb4d7167043ae2be.zip
cpython-747720540ccbf0c567c80d19bb4d7167043ae2be.tar.gz
cpython-747720540ccbf0c567c80d19bb4d7167043ae2be.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pydoc.py33
-rw-r--r--Lib/test/test_sundry.py1
2 files changed, 33 insertions, 1 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
new file mode 100644
index 0000000..8f0dc73
--- /dev/null
+++ b/Lib/test/test_pydoc.py
@@ -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()
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index 23b145e..1dcfaeb 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -90,7 +90,6 @@ class TestUntestedModules(unittest.TestCase):
import posixfile
import pstats
import py_compile
- import pydoc
import rexec
import rlcompleter
import sched