]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a few tests for pydoc.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 20:22:26 +0000 (20:22 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 20:22:26 +0000 (20:22 +0000)
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.

Lib/test/test_pydoc.py [new file with mode: 0644]
Lib/test/test_sundry.py

diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
new file mode 100644 (file)
index 0000000..8f0dc73
--- /dev/null
@@ -0,0 +1,33 @@
+from test import test_support\r
+import unittest\r
+import pydoc\r
+\r
+class TestDescriptions(unittest.TestCase):\r
+    def test_module(self):\r
+        # Check that pydocfodder module can be described\r
+        import pydocfodder\r
+        doc = pydoc.render_doc(pydocfodder)\r
+        assert "pydocfodder" in doc\r
+\r
+    def test_classic_class(self):\r
+        class C: "Classic class"\r
+        c = C()\r
+        self.failUnlessEqual(pydoc.describe(C), 'class C')\r
+        self.failUnlessEqual(pydoc.describe(c), 'instance of C')\r
+        self.failUnless('instance of C in module test.test_pydoc'\r
+                        in pydoc.render_doc(c))\r
+\r
+    def test_class(self):\r
+        class C(object): "New-style class"\r
+        c = C()\r
+\r
+        self.failUnlessEqual(pydoc.describe(C), 'class C')\r
+        self.failUnlessEqual(pydoc.describe(c), 'C')\r
+        self.failUnless('C in module test.test_pydoc object'\r
+                        in pydoc.render_doc(c))\r
+\r
+def test_main():\r
+    test_support.run_unittest(TestDescriptions)\r
+\r
+if __name__ == "__main__":\r
+    unittest.main()\r
index 23b145e66163e5f01cd0cbb88d32bb44a58adb62..1dcfaebe1f9df0611512d5644b61f60a809046de 100644 (file)
@@ -90,7 +90,6 @@ class TestUntestedModules(unittest.TestCase):
             import posixfile
             import pstats
             import py_compile
-            import pydoc
             import rexec
             import rlcompleter
             import sched