mirror of https://github.com/python/cpython
Closing the HTTP connection after each test, and listening more.
This commit is contained in:
parent
b8af7bcad5
commit
f196629eba
|
@ -160,7 +160,7 @@ class TimeoutTest(TestCase):
|
||||||
self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
global PORT
|
global PORT
|
||||||
PORT = test_support.bind_port(self.serv, HOST, PORT)
|
PORT = test_support.bind_port(self.serv, HOST, PORT)
|
||||||
self.serv.listen(1)
|
self.serv.listen(5)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.serv.close()
|
self.serv.close()
|
||||||
|
@ -174,11 +174,13 @@ class TimeoutTest(TestCase):
|
||||||
httpConn = httplib.HTTPConnection(HOST, PORT)
|
httpConn = httplib.HTTPConnection(HOST, PORT)
|
||||||
httpConn.connect()
|
httpConn.connect()
|
||||||
self.assertTrue(httpConn.sock.gettimeout() is None)
|
self.assertTrue(httpConn.sock.gettimeout() is None)
|
||||||
|
httpConn.close()
|
||||||
|
|
||||||
# a value
|
# a value
|
||||||
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=30)
|
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=30)
|
||||||
httpConn.connect()
|
httpConn.connect()
|
||||||
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
||||||
|
httpConn.close()
|
||||||
|
|
||||||
# None, having other default
|
# None, having other default
|
||||||
previous = socket.getdefaulttimeout()
|
previous = socket.getdefaulttimeout()
|
||||||
|
@ -189,6 +191,7 @@ class TimeoutTest(TestCase):
|
||||||
finally:
|
finally:
|
||||||
socket.setdefaulttimeout(previous)
|
socket.setdefaulttimeout(previous)
|
||||||
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
||||||
|
httpConn.close()
|
||||||
|
|
||||||
|
|
||||||
def test_main(verbose=None):
|
def test_main(verbose=None):
|
||||||
|
|
Loading…
Reference in New Issue