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:
Facundo Batista 2007-03-23 20:23:08 +00:00
parent e6a7039451
commit 14553b08a1
2 changed files with 20 additions and 16 deletions

View file

@ -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):