summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-27 18:55:54 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-27 18:55:54 (GMT)
commit412dc9c88f040abf4b23017c5e5e4d8b880d247d (patch)
treee10dee1ac8404c0d3362c48a4350d8e8389b7789 /Lib
parent661b0a15d78b8e86ea4b458550b1cb04f0988424 (diff)
downloadcpython-412dc9c88f040abf4b23017c5e5e4d8b880d247d.zip
cpython-412dc9c88f040abf4b23017c5e5e4d8b880d247d.tar.gz
cpython-412dc9c88f040abf4b23017c5e5e4d8b880d247d.tar.bz2
Merged revisions 60350-60363 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r60355 | neal.norwitz | 2008-01-27 18:10:14 +0100 (Sun, 27 Jan 2008) | 1 line Whitespace cleanup ........ r60356 | neal.norwitz | 2008-01-27 18:10:29 +0100 (Sun, 27 Jan 2008) | 1 line Add assertion that we do not blow out newl ........ r60357 | neal.norwitz | 2008-01-27 18:10:35 +0100 (Sun, 27 Jan 2008) | 1 line Initialize variable to prevent warning on some platform/config. ........ r60358 | neal.norwitz | 2008-01-27 18:10:43 +0100 (Sun, 27 Jan 2008) | 1 line Update to newer version of ffi. Fixes crashes and test failures of longdouble ........ r60359 | neal.norwitz | 2008-01-27 18:10:50 +0100 (Sun, 27 Jan 2008) | 1 line Add a tiny sleep and additional flush to force the file to really be synced. ........ r60360 | neal.norwitz | 2008-01-27 18:10:58 +0100 (Sun, 27 Jan 2008) | 1 line Retry connection in case it fails to reduce flakiness ........ r60361 | neal.norwitz | 2008-01-27 18:11:11 +0100 (Sun, 27 Jan 2008) | 4 lines Catch socket errors that are often the cause of transient failures. Many of these exceptions are due to resource unavailable, so the existing code should be able to handle many more spurious errors. ........ r60362 | neal.norwitz | 2008-01-27 18:12:15 +0100 (Sun, 27 Jan 2008) | 1 line Reduce buffer size since we do not need 1k ........ r60363 | neal.norwitz | 2008-01-27 18:13:07 +0100 (Sun, 27 Jan 2008) | 1 line Print periodic "still working" messages since this suite is slow. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bsddb3.py26
-rw-r--r--Lib/test/test_resource.py7
-rw-r--r--Lib/test/test_xmlrpc.py75
3 files changed, 77 insertions, 31 deletions
diff --git a/Lib/test/test_bsddb3.py b/Lib/test/test_bsddb3.py
index 15ed1e4..a88b113 100644
--- a/Lib/test/test_bsddb3.py
+++ b/Lib/test/test_bsddb3.py
@@ -3,6 +3,7 @@
Run all test cases.
"""
import sys
+import time
import unittest
import test.test_support
from test.test_support import requires, run_unittest, unlink
@@ -22,6 +23,30 @@ if 'silent' in sys.argv: # take care of old flag, just in case
sys.argv.remove('silent')
+class TimingCheck(unittest.TestCase):
+
+ """This class is not a real test. Its purpose is to print a message
+ periodically when the test runs slowly. This will prevent the buildbots
+ from timing out on slow machines."""
+
+ # How much time in seconds before printing a 'Still working' message.
+ # Since this is run at most once between each test module, use a smaller
+ # interval than other tests.
+ _PRINT_WORKING_MSG_INTERVAL = 4 * 60
+
+ # next_time is used as a global variable that survives each instance.
+ # This is necessary since a new instance will be created for each test.
+ next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
+
+ def testCheckElapsedTime(self):
+ # Print still working message since these tests can be really slow.
+ now = time.time()
+ if self.next_time <= now:
+ TimingCheck.next_time = now + self._PRINT_WORKING_MSG_INTERVAL
+ sys.__stdout__.write(' test_bsddb3 still working, be patient...\n')
+ sys.__stdout__.flush()
+
+
def suite():
try:
# this is special, it used to segfault the interpreter
@@ -56,6 +81,7 @@ def suite():
module = __import__("bsddb.test."+name, globals(), locals(), name)
#print module,name
alltests.addTest(module.test_suite())
+ alltests.addTest(unittest.makeSuite(TimingCheck))
return alltests
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 987c8d7..43ff372 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -1,8 +1,9 @@
import unittest
from test import test_support
-
-import os, resource
+import os
+import resource
+import time
# This test is checking a few specific problem spots with the resource module.
@@ -59,6 +60,8 @@ class ResourceTest(unittest.TestCase):
# an attempt to ensure the file is really synced and
# the exception raised.
for i in range(5):
+ time.sleep(.1)
+ f.flush()
f.close()
except IOError:
if not limit_set:
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 7b5af9e..28cbf0c 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -345,9 +345,11 @@ class SimpleServerTestCase(unittest.TestCase):
try:
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
self.assertEqual(p.pow(6,8), 6**8)
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
# [ch] The test 404 is causing lots of false alarms.
def XXXtest_404(self):
@@ -369,9 +371,12 @@ class SimpleServerTestCase(unittest.TestCase):
'system.listMethods', 'system.methodHelp',
'system.methodSignature', 'system.multicall'])
self.assertEqual(set(meth), expected_methods)
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
+
def test_introspection2(self):
try:
@@ -379,9 +384,11 @@ class SimpleServerTestCase(unittest.TestCase):
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
divhelp = p.system.methodHelp('div')
self.assertEqual(divhelp, 'This is the div function')
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
def test_introspection3(self):
try:
@@ -389,7 +396,7 @@ class SimpleServerTestCase(unittest.TestCase):
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
myfunction = p.system.methodHelp('my_function')
self.assertEqual(myfunction, 'This is my function')
- except xmlrpclib.ProtocolError as e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -402,9 +409,11 @@ class SimpleServerTestCase(unittest.TestCase):
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
divsig = p.system.methodSignature('div')
self.assertEqual(divsig, 'signatures not supported')
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
def test_multicall(self):
try:
@@ -417,9 +426,11 @@ class SimpleServerTestCase(unittest.TestCase):
self.assertEqual(add_result, 2+3)
self.assertEqual(pow_result, 6**8)
self.assertEqual(div_result, 127//42)
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
def test_non_existing_multicall(self):
try:
@@ -436,7 +447,7 @@ class SimpleServerTestCase(unittest.TestCase):
self.assertEqual(result.results[0]['faultString'],
'<type \'Exception\'>:method "this_is_not_exists" '
'is not supported')
- except xmlrpclib.ProtocolError as e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -483,9 +494,11 @@ class FailingServerTestCase(unittest.TestCase):
try:
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
self.assertEqual(p.pow(6,8), 6**8)
- except xmlrpclib.ProtocolError as e:
- # protocol error; provide additional information in test output
- self.fail("%s\n%s" % (e, e.headers))
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # 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))
def test_fail_no_info(self):
# use the broken message class
@@ -494,10 +507,12 @@ class FailingServerTestCase(unittest.TestCase):
try:
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
p.pow(6,8)
- except xmlrpclib.ProtocolError as e:
- # 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)
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # ignore failures due to non-blocking socket 'unavailable' errors
+ if not is_unavailable_exception(e):
+ # 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)
else:
self.fail('ProtocolError not raised')
@@ -512,11 +527,13 @@ class FailingServerTestCase(unittest.TestCase):
try:
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
p.pow(6,8)
- except xmlrpclib.ProtocolError as e:
- # 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)
- self.assertTrue(e.headers.get("x-traceback") is not None)
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ # ignore failures due to non-blocking socket 'unavailable' errors
+ if not is_unavailable_exception(e):
+ # 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)
+ self.assertTrue(e.headers.get("x-traceback") is not None)
else:
self.fail('ProtocolError not raised')