~pythonregexp2.7/python/issue2636-01

« back to all changes in this revision

Viewing changes to Lib/test/test_httplib.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:37:21 UTC
  • mfrom: (39022.1.14 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609143721-bj0g1mwta28038da
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
        '''This will prove that the timeout gets through
215
215
        HTTPConnection and into the socket.
216
216
        '''
217
 
        # default
218
 
        httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT)
219
 
        httpConn.connect()
220
 
        self.assertTrue(httpConn.sock.gettimeout() is None)
 
217
        # default -- use global socket timeout
 
218
        self.assert_(socket.getdefaulttimeout() is None)
 
219
        socket.setdefaulttimeout(30)
 
220
        try:
 
221
            httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT)
 
222
            httpConn.connect()
 
223
        finally:
 
224
            socket.setdefaulttimeout(None)
 
225
        self.assertEqual(httpConn.sock.gettimeout(), 30)
 
226
        httpConn.close()
 
227
 
 
228
        # no timeout -- do not use global socket default
 
229
        self.assert_(socket.getdefaulttimeout() is None)
 
230
        socket.setdefaulttimeout(30)
 
231
        try:
 
232
            httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT,
 
233
                                              timeout=None)
 
234
            httpConn.connect()
 
235
        finally:
 
236
            socket.setdefaulttimeout(None)
 
237
        self.assertEqual(httpConn.sock.gettimeout(), None)
221
238
        httpConn.close()
222
239
 
223
240
        # a value
226
243
        self.assertEqual(httpConn.sock.gettimeout(), 30)
227
244
        httpConn.close()
228
245
 
229
 
        # None, having other default
230
 
        previous = socket.getdefaulttimeout()
231
 
        socket.setdefaulttimeout(30)
232
 
        try:
233
 
            httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT,
234
 
                                              timeout=None)
235
 
            httpConn.connect()
236
 
        finally:
237
 
            socket.setdefaulttimeout(previous)
238
 
        self.assertEqual(httpConn.sock.gettimeout(), 30)
239
 
        httpConn.close()
240
 
 
241
246
 
242
247
class HTTPSTimeoutTest(TestCase):
243
248
# XXX Here should be tests for HTTPS, there isn't any right now!