diff Lib/test/test_docxmlrpc.py @ 59091:8d3ff2fbbe4b

Merged revisions 78351 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78351 | r.david.murray | 2010-02-22 19:24:49 -0500 (Mon, 22 Feb 2010) | 5 lines Issue 6292: for the moment at least, the test suite passes if run with -OO. Tests requiring docstrings are skipped. Patch by Brian Curtin, thanks to Matias Torchinsky for helping review and improve the patch. ........
author R. David Murray <rdmurray@bitdance.com>
date Wed, 24 Feb 2010 01:46:21 +0000
parents f0f221e1a7c0
children 77c71f258df7
line wrap: on
line diff
--- a/Lib/test/test_docxmlrpc.py	Wed Feb 24 00:10:48 2010 +0000
+++ b/Lib/test/test_docxmlrpc.py	Wed Feb 24 01:46:21 2010 +0000
@@ -1,5 +1,6 @@
 from xmlrpc.server import DocXMLRPCServer
 import http.client
+import sys
 from test import support
 import threading
 import time
@@ -7,6 +8,20 @@
 
 PORT = None
 
+def make_request_and_skipIf(condition, reason):
+    # If we skip the test, we have to make a request because the
+    # the server created in setUp blocks expecting one to come in.
+    if not condition:
+        return lambda func: func
+    def decorator(func):
+        def make_request_and_skip(self):
+            self.client.request("GET", "/")
+            self.client.getresponse()
+            raise unittest.SkipTest(reason)
+        return make_request_and_skip
+    return decorator
+
+
 def server(evt, numrequests):
     serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
 
@@ -110,10 +125,12 @@
                        b'&lt;lambda&gt;</strong></a>(x, y)</dt></dl>'),
                       response.read())
 
+    @make_request_and_skipIf(sys.flags.optimize >= 2,
+                     "Docstrings are omitted with -O2 and above")
     def test_autolinking(self):
-        """Test that the server correctly automatically wraps references to PEPS
-        and RFCs with links, and that it linkifies text starting with http or
-        ftp protocol prefixes.
+        """Test that the server correctly automatically wraps references to
+        PEPS and RFCs with links, and that it linkifies text starting with
+        http or ftp protocol prefixes.
 
         The documentation for the "add" method contains the test material.
         """
@@ -132,11 +149,13 @@
              b'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">'
              b'http://google.com</a>.</tt></dd></dl>'), response)
 
+    @make_request_and_skipIf(sys.flags.optimize >= 2,
+                     "Docstrings are omitted with -O2 and above")
     def test_system_methods(self):
         """Test the precense of three consecutive system.* methods.
 
-        This also tests their use of parameter type recognition and the systems
-        related to that process.
+        This also tests their use of parameter type recognition and the
+        systems related to that process.
         """
         self.client.request("GET", "/")
         response = self.client.getresponse().read()