mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Surrounded with try/finally to socket's default timeout setting
changes in the tests, so failing one test won't produce strange results in others. Also relaxed the timeout settings in the test (where actually the value didn't mean anything).
This commit is contained in:
parent
e6a7039451
commit
14553b08a1
2 changed files with 20 additions and 16 deletions
|
|
@ -176,17 +176,19 @@ class TimeoutTest(TestCase):
|
|||
self.assertTrue(httpConn.sock.gettimeout() is None)
|
||||
|
||||
# a value
|
||||
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=10)
|
||||
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=30)
|
||||
httpConn.connect()
|
||||
self.assertEqual(httpConn.sock.gettimeout(), 10)
|
||||
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
||||
|
||||
# None, having other default
|
||||
previous = socket.getdefaulttimeout()
|
||||
socket.setdefaulttimeout(10)
|
||||
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=None)
|
||||
httpConn.connect()
|
||||
socket.setdefaulttimeout(previous)
|
||||
self.assertEqual(httpConn.sock.gettimeout(), 10)
|
||||
socket.setdefaulttimeout(30)
|
||||
try:
|
||||
httpConn = httplib.HTTPConnection(HOST, PORT, timeout=None)
|
||||
httpConn.connect()
|
||||
finally:
|
||||
socket.setdefaulttimeout(previous)
|
||||
self.assertEqual(httpConn.sock.gettimeout(), 30)
|
||||
|
||||
|
||||
def test_main(verbose=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue