]> granicus.if.org Git - python/commitdiff
Merged revisions 62486-62487 via svnmerge from
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 20:48:12 +0000 (20:48 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 20:48:12 +0000 (20:48 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62486 | amaury.forgeotdarc | 2008-04-24 16:22:26 -0400 (Thu, 24 Apr 2008) | 7 lines

  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.
........
  r62487 | amaury.forgeotdarc | 2008-04-24 16:41:50 -0400 (Thu, 24 Apr 2008) | 2 lines

  Use absolute import for test package
........

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..d9670fb
--- /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
+        from test 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 64a96906b3383f1f7ca3f007deac5f1d24e6de63..77d3f88dc1ee6627ab2417ba5d43eb14ea0f2ec1 100644 (file)
@@ -86,7 +86,6 @@ class TestUntestedModules(unittest.TestCase):
             import pdb
             import pstats
             import py_compile
-            import pydoc
             import rlcompleter
             import sched
             import smtplib