[Python-3000-checkins] r59424 - python/branches/py3k/Lib/test/test_xmlrpc.py
Guido van Rossum
guido at python.org
Mon Dec 10 18:36:19 CET 2007
I'm not sure I'd bother backporting something that only affects the tests.
I do think that we could do with more support for unit tests that
create a server in a thread; there seem to be a few somewhat faulty
patterns that have been copied over and over and then have to be fixed
each time we think of an improvement.
--Guido
On Dec 8, 2007 9:09 AM, christian.heimes
<python-3000-checkins at python.org> wrote:
> Author: christian.heimes
> Date: Sat Dec 8 18:09:18 2007
> New Revision: 59424
>
> Modified:
> python/branches/py3k/Lib/test/test_xmlrpc.py
> Log:
> Added stop_serving and a timeout to tearDown()
> It prevents the XML RPC tests from blocking until the end of the world.
> I think it's a backport candidate and other modules may benefit from the feature, too.
>
> Modified: python/branches/py3k/Lib/test/test_xmlrpc.py
> ==============================================================================
> --- python/branches/py3k/Lib/test/test_xmlrpc.py (original)
> +++ python/branches/py3k/Lib/test/test_xmlrpc.py Sat Dec 8 18:09:18 2007
> @@ -293,6 +293,14 @@
> PORT = None
> evt.set()
>
> +def stop_serving():
> + global PORT
> + if PORT is None:
> + return
> + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> + sock.connect(('localhost', int(PORT)))
> + sock.send(b"")
> + sock.close()
>
>
> class SimpleServerTestCase(unittest.TestCase):
> @@ -315,7 +323,11 @@
>
> def tearDown(self):
> # wait on the server thread to terminate
> - self.evt.wait()
> + self.evt.wait(4.0)
> + if not self.evt.isSet():
> + self.evt.set()
> + stop_serving()
> + raise RuntimeError("timeout reached, test has failed")
>
> # disable traceback reporting
> SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
> @@ -328,7 +340,7 @@
> # protocol error; provide additional information in test output
> self.fail("%s\n%s" % (e, e.headers))
>
> - def DISABLED_test_404(self):
> + def test_404(self):
> # send POST with httplib, it should return 404 header and
> # 'Not Found' message.
> conn = httplib.HTTPConnection('localhost', PORT)
> _______________________________________________
> Python-3000-checkins mailing list
> Python-3000-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000-checkins
mailing list