MCPcopy Index your code
hub / github.com/python/cpython / testTimeoutAttribute

Method testTimeoutAttribute

Lib/test/test_httplib.py:1944–1975  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1942 self.serv = None
1943
1944 def testTimeoutAttribute(self):
1945 # This will prove that the timeout gets through HTTPConnection
1946 # and into the socket.
1947
1948 # default -- use global socket timeout
1949 self.assertIsNone(socket.getdefaulttimeout())
1950 socket.setdefaulttimeout(30)
1951 try:
1952 httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT)
1953 httpConn.connect()
1954 finally:
1955 socket.setdefaulttimeout(None)
1956 self.assertEqual(httpConn.sock.gettimeout(), 30)
1957 httpConn.close()
1958
1959 # no timeout -- do not use global socket default
1960 self.assertIsNone(socket.getdefaulttimeout())
1961 socket.setdefaulttimeout(30)
1962 try:
1963 httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT,
1964 timeout=None)
1965 httpConn.connect()
1966 finally:
1967 socket.setdefaulttimeout(None)
1968 self.assertEqual(httpConn.sock.gettimeout(), None)
1969 httpConn.close()
1970
1971 # a value
1972 httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30)
1973 httpConn.connect()
1974 self.assertEqual(httpConn.sock.gettimeout(), 30)
1975 httpConn.close()
1976
1977
1978class PersistenceTest(TestCase):

Callers

nothing calls this directly

Calls 5

connectMethod · 0.95
closeMethod · 0.95
assertIsNoneMethod · 0.80
assertEqualMethod · 0.45
gettimeoutMethod · 0.45

Tested by

no test coverage detected