diff options
author | Christian Heimes <christian@cheimes.de> | 2008-01-27 23:50:43 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-01-27 23:50:43 (GMT) |
commit | 26855635833fcd3f15786b4a9d4241ded293404c (patch) | |
tree | 37e1984aadfd2e688e7105ce112e3559bf93653e /Lib/test/test_xmlrpc.py | |
parent | 7b69c6c3afba79518865313e1b41845a6b534fb6 (diff) | |
download | cpython-26855635833fcd3f15786b4a9d4241ded293404c.zip cpython-26855635833fcd3f15786b4a9d4241ded293404c.tar.gz cpython-26855635833fcd3f15786b4a9d4241ded293404c.tar.bz2 |
Merged revisions 60364-60378 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60364 | neal.norwitz | 2008-01-27 19:09:48 +0100 (Sun, 27 Jan 2008) | 4 lines
Update the comment and remove the close. If we close we can't flush anymore.
We might still need to close after the for loop if flushing 6! times still
doesn't cause the signal/exception.
........
r60365 | georg.brandl | 2008-01-27 19:14:43 +0100 (Sun, 27 Jan 2008) | 2 lines
Remove effectless expression statement.
........
r60367 | neal.norwitz | 2008-01-27 19:19:04 +0100 (Sun, 27 Jan 2008) | 1 line
Try to handle socket.errors properly in is_unavailable
........
r60370 | christian.heimes | 2008-01-27 20:01:45 +0100 (Sun, 27 Jan 2008) | 1 line
Change isbasestring function as discussed on the cvs list a while ago
........
r60372 | neal.norwitz | 2008-01-27 21:03:13 +0100 (Sun, 27 Jan 2008) | 3 lines
socket.error doesn't have a headers attribute like ProtocolError.
Handle that situation where we catch socket.errors.
........
r60375 | georg.brandl | 2008-01-27 21:25:12 +0100 (Sun, 27 Jan 2008) | 2 lines
Add refcounting extension to build config.
........
r60377 | jeffrey.yasskin | 2008-01-28 00:08:46 +0100 (Mon, 28 Jan 2008) | 6 lines
Moved Rational._binary_float_to_ratio() to float.as_integer_ratio() because
it's useful outside of rational numbers.
This is my first C code that had to do anything significant. Please be more
careful when looking over it.
........
r60378 | christian.heimes | 2008-01-28 00:34:59 +0100 (Mon, 28 Jan 2008) | 1 line
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
........
Diffstat (limited to 'Lib/test/test_xmlrpc.py')
-rw-r--r-- | Lib/test/test_xmlrpc.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 28cbf0c..092be51 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -312,10 +312,17 @@ def is_unavailable_exception(e): given by operations on non-blocking sockets.''' # sometimes we get a -1 error code and/or empty headers - if e.errcode == -1 or e.headers is None: + try: + if e.errcode == -1 or e.headers is None: + return True + exc_mess = e.headers.get('X-exception') + except AttributeError: + # Ignore socket.errors here. + exc_mess = str(e) + + if exc_mess and 'temporarily unavailable' in exc_mess.lower(): return True - class SimpleServerTestCase(unittest.TestCase): def setUp(self): # enable traceback reporting @@ -349,7 +356,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) # [ch] The test 404 is causing lots of false alarms. def XXXtest_404(self): @@ -375,7 +382,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_introspection2(self): @@ -388,7 +395,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_introspection3(self): try: @@ -400,7 +407,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_introspection4(self): # the SimpleXMLRPCServer doesn't support signatures, but @@ -413,7 +420,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_multicall(self): try: @@ -430,7 +437,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_non_existing_multicall(self): try: @@ -451,7 +458,7 @@ class SimpleServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) # This is a contrived way to make a failure occur on the server side # in order to test the _send_traceback_header flag on the server @@ -498,7 +505,7 @@ class FailingServerTestCase(unittest.TestCase): # ignore failures due to non-blocking socket 'unavailable' errors if not is_unavailable_exception(e): # protocol error; provide additional information in test output - self.fail("%s\n%s" % (e, e.headers)) + self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) def test_fail_no_info(self): # use the broken message class @@ -509,7 +516,7 @@ class FailingServerTestCase(unittest.TestCase): p.pow(6,8) except (xmlrpclib.ProtocolError, socket.error) as e: # ignore failures due to non-blocking socket 'unavailable' errors - if not is_unavailable_exception(e): + if not is_unavailable_exception(e) and hasattr(e, "headers"): # The two server-side error headers shouldn't be sent back in this case self.assertTrue(e.headers.get("X-exception") is None) self.assertTrue(e.headers.get("X-traceback") is None) @@ -529,7 +536,7 @@ class FailingServerTestCase(unittest.TestCase): p.pow(6,8) except (xmlrpclib.ProtocolError, socket.error) as e: # ignore failures due to non-blocking socket 'unavailable' errors - if not is_unavailable_exception(e): + if not is_unavailable_exception(e) and hasattr(e, "headers"): # We should get error info in the response expected_err = "invalid literal for int() with base 10: 'I am broken'" self.assertEqual(e.headers.get("x-exception"), expected_err) |