mirror of https://github.com/python/cpython.git
Re-enable all tests for windows platforms.
Also, explicitly connect to the IPV4 address. On windows platforms supporting AF_INET6, the SocketProxy would connect using socket.create_connection('localhost', port) which would cycle through all address families and try to connect. It would try connecting using AF_INET6 first and this would cause a delay of up to a second.
This commit is contained in:
parent
2950bca89c
commit
018760e3dc
|
@ -267,7 +267,7 @@ def test_decode(self):
|
||||||
self.assertEqual(str(t2), d)
|
self.assertEqual(str(t2), d)
|
||||||
|
|
||||||
|
|
||||||
PORT = None
|
ADDR = PORT = URL = None
|
||||||
|
|
||||||
# The evt is set twice. First when the server is ready to serve.
|
# The evt is set twice. First when the server is ready to serve.
|
||||||
# Second when the server has been shutdown. The user must clear
|
# Second when the server has been shutdown. The user must clear
|
||||||
|
@ -293,13 +293,18 @@ def get_request(self):
|
||||||
s.setblocking(True)
|
s.setblocking(True)
|
||||||
return s, port
|
return s, port
|
||||||
|
|
||||||
|
serv = MyXMLRPCServer(("localhost", 0),
|
||||||
|
logRequests=False, bind_and_activate=False)
|
||||||
try:
|
try:
|
||||||
serv = MyXMLRPCServer(("localhost", 0),
|
|
||||||
logRequests=False, bind_and_activate=False)
|
|
||||||
serv.socket.settimeout(3)
|
serv.socket.settimeout(3)
|
||||||
serv.server_bind()
|
serv.server_bind()
|
||||||
global PORT
|
global ADDR, PORT, URL
|
||||||
PORT = serv.socket.getsockname()[1]
|
ADDR, PORT = serv.socket.getsockname()
|
||||||
|
#connect to IP address directly. This avoids socket.create_connection()
|
||||||
|
#trying to connect to to "localhost" using all address families, which
|
||||||
|
#causes slowdown e.g. on vista which supports AF_INET6. The server listens
|
||||||
|
#on AF_INET only.
|
||||||
|
URL = "http://%s:%d"%(ADDR, PORT)
|
||||||
serv.server_activate()
|
serv.server_activate()
|
||||||
serv.register_introspection_functions()
|
serv.register_introspection_functions()
|
||||||
serv.register_multicall_functions()
|
serv.register_multicall_functions()
|
||||||
|
@ -372,7 +377,7 @@ def tearDown(self):
|
||||||
|
|
||||||
def test_simple1(self):
|
def test_simple1(self):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
self.assertEqual(p.pow(6,8), 6**8)
|
self.assertEqual(p.pow(6,8), 6**8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
|
@ -384,7 +389,7 @@ def test_simple1(self):
|
||||||
def XXXtest_404(self):
|
def XXXtest_404(self):
|
||||||
# send POST with httplib, it should return 404 header and
|
# send POST with httplib, it should return 404 header and
|
||||||
# 'Not Found' message.
|
# 'Not Found' message.
|
||||||
conn = httplib.HTTPConnection('localhost', PORT)
|
conn = httplib.HTTPConnection(ADDR, PORT)
|
||||||
conn.request('POST', '/this-is-not-valid')
|
conn.request('POST', '/this-is-not-valid')
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
@ -394,7 +399,7 @@ def XXXtest_404(self):
|
||||||
|
|
||||||
def test_introspection1(self):
|
def test_introspection1(self):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
meth = p.system.listMethods()
|
meth = p.system.listMethods()
|
||||||
expected_methods = set(['pow', 'div', 'my_function', 'add',
|
expected_methods = set(['pow', 'div', 'my_function', 'add',
|
||||||
'system.listMethods', 'system.methodHelp',
|
'system.listMethods', 'system.methodHelp',
|
||||||
|
@ -409,7 +414,7 @@ def test_introspection1(self):
|
||||||
def test_introspection2(self):
|
def test_introspection2(self):
|
||||||
try:
|
try:
|
||||||
# test _methodHelp()
|
# test _methodHelp()
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
divhelp = p.system.methodHelp('div')
|
divhelp = p.system.methodHelp('div')
|
||||||
self.assertEqual(divhelp, 'This is the div function')
|
self.assertEqual(divhelp, 'This is the div function')
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
|
@ -421,7 +426,7 @@ def test_introspection2(self):
|
||||||
def test_introspection3(self):
|
def test_introspection3(self):
|
||||||
try:
|
try:
|
||||||
# test native doc
|
# test native doc
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
myfunction = p.system.methodHelp('my_function')
|
myfunction = p.system.methodHelp('my_function')
|
||||||
self.assertEqual(myfunction, 'This is my function')
|
self.assertEqual(myfunction, 'This is my function')
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
|
@ -434,7 +439,7 @@ def test_introspection4(self):
|
||||||
# the SimpleXMLRPCServer doesn't support signatures, but
|
# the SimpleXMLRPCServer doesn't support signatures, but
|
||||||
# at least check that we can try making the call
|
# at least check that we can try making the call
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
divsig = p.system.methodSignature('div')
|
divsig = p.system.methodSignature('div')
|
||||||
self.assertEqual(divsig, 'signatures not supported')
|
self.assertEqual(divsig, 'signatures not supported')
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
|
@ -445,7 +450,7 @@ def test_introspection4(self):
|
||||||
|
|
||||||
def test_multicall(self):
|
def test_multicall(self):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
multicall = xmlrpclib.MultiCall(p)
|
multicall = xmlrpclib.MultiCall(p)
|
||||||
multicall.add(2,3)
|
multicall.add(2,3)
|
||||||
multicall.pow(6,8)
|
multicall.pow(6,8)
|
||||||
|
@ -462,7 +467,7 @@ def test_multicall(self):
|
||||||
|
|
||||||
def test_non_existing_multicall(self):
|
def test_non_existing_multicall(self):
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
multicall = xmlrpclib.MultiCall(p)
|
multicall = xmlrpclib.MultiCall(p)
|
||||||
multicall.this_is_not_exists()
|
multicall.this_is_not_exists()
|
||||||
result = multicall()
|
result = multicall()
|
||||||
|
@ -530,7 +535,7 @@ def test_basic(self):
|
||||||
|
|
||||||
# test a call that shouldn't fail just as a smoke test
|
# test a call that shouldn't fail just as a smoke test
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
self.assertEqual(p.pow(6,8), 6**8)
|
self.assertEqual(p.pow(6,8), 6**8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
|
@ -543,7 +548,7 @@ def test_fail_no_info(self):
|
||||||
SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
|
SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
p.pow(6,8)
|
p.pow(6,8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
|
@ -563,7 +568,7 @@ def test_fail_with_info(self):
|
||||||
SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
|
SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
|
p = xmlrpclib.ServerProxy(URL)
|
||||||
p.pow(6,8)
|
p.pow(6,8)
|
||||||
except (xmlrpclib.ProtocolError, socket.error), e:
|
except (xmlrpclib.ProtocolError, socket.error), e:
|
||||||
# ignore failures due to non-blocking socket 'unavailable' errors
|
# ignore failures due to non-blocking socket 'unavailable' errors
|
||||||
|
@ -727,15 +732,9 @@ def send_content(self, conn, body):
|
||||||
def test_main():
|
def test_main():
|
||||||
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
|
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
|
||||||
BinaryTestCase, FaultTestCase, TransportSubclassTestCase]
|
BinaryTestCase, FaultTestCase, TransportSubclassTestCase]
|
||||||
|
xmlrpc_tests.append(SimpleServerTestCase)
|
||||||
# The test cases against a SimpleXMLRPCServer raise a socket error
|
xmlrpc_tests.append(FailingServerTestCase)
|
||||||
# 10035 (WSAEWOULDBLOCK) in the server thread handle_request call when
|
xmlrpc_tests.append(CGIHandlerTestCase)
|
||||||
# run on Windows. This only happens on the first test to run, but it
|
|
||||||
# fails every time and so these tests are skipped on win32 platforms.
|
|
||||||
if sys.platform != 'win32':
|
|
||||||
xmlrpc_tests.append(SimpleServerTestCase)
|
|
||||||
xmlrpc_tests.append(FailingServerTestCase)
|
|
||||||
xmlrpc_tests.append(CGIHandlerTestCase)
|
|
||||||
|
|
||||||
test_support.run_unittest(*xmlrpc_tests)
|
test_support.run_unittest(*xmlrpc_tests)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue