diff Lib/test/test_xmlrpc.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 71acd4482e65
children 493bb4585e38
line wrap: on
line diff
--- a/Lib/test/test_xmlrpc.py	Wed Feb 24 00:10:48 2010 +0000
+++ b/Lib/test/test_xmlrpc.py	Wed Feb 24 01:46:21 2010 +0000
@@ -383,6 +383,22 @@
     if exc_mess and 'temporarily unavailable' in exc_mess.lower():
         return True
 
+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):
+            try:
+                xmlrpclib.ServerProxy(URL).my_function()
+            except (xmlrpclib.ProtocolError, socket.error) as e:
+                if not is_unavailable_exception(e):
+                    raise
+            raise unittest.SkipTest(reason)
+        return make_request_and_skip
+    return decorator
+
 class BaseServerTestCase(unittest.TestCase):
     requestHandler = None
     request_count = 1
@@ -403,6 +419,7 @@
     def tearDown(self):
         # wait on the server thread to terminate
         self.evt.wait(4.0)
+        # XXX this code does not work, and in fact stop_serving doesn't exist.
         if not self.evt.is_set():
             self.evt.set()
             stop_serving()
@@ -474,6 +491,8 @@
                 # protocol error; provide additional information in test output
                 self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
 
+    @make_request_and_skipIf(sys.flags.optimize >= 2,
+                     "Docstrings are omitted with -O2 and above")
     def test_introspection3(self):
         try:
             # test native doc