Skip to content
This repository
  • 2 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
Apr 26, 2012
Ian Bicking Be more aware of when timeouts are supported, and only test timeout s…
…upport when it is available (not Python 2.6 and earlier, when using httplib)
d5a0ad7
Ian Bicking Merge branch 'master' of github.com:Pylons/webob 63b0236
5  tests/test_client.py
@@ -59,6 +59,11 @@ def slow_app(req):
59 59
 
60 60
 
61 61
 def test_client_slow(client_app=None):
  62
+    if client_app is None:
  63
+        client_app = SendRequest()
  64
+    if not client_app._timeout_supported(client_app.HTTPConnection):
  65
+        # timeout isn't supported
  66
+        return
62 67
     with serve(slow_app) as server:
63 68
         req = Request.blank(server.url)
64 69
         req.environ['webob.client.timeout'] = 0.1
7  webob/client.py
@@ -67,7 +67,7 @@ def __call__(self, environ, start_response):
67 67
             environ['SERVER_NAME'] = host
68 68
             environ['SERVER_PORT'] = port
69 69
         kw = {}
70  
-        if sys.version_info >= (2, 7) and 'webob.client.timeout' in environ:
  70
+        if 'webob.client.timeout' in environ and self._timeout_supported(ConnClass):
71 71
             kw['timeout'] = environ['webob.client.timeout']
72 72
         conn = ConnClass('%(SERVER_NAME)s:%(SERVER_PORT)s' % environ, **kw)
73 73
         headers = {}
@@ -172,5 +172,10 @@ def parse_headers(self, message):
172 172
                 headers_out.append((header, value))
173 173
         return headers_out
174 174
 
  175
+    def _timeout_supported(self, ConnClass):
  176
+        if sys.version_info < (2, 7) and ConnClass in (httplib.HTTPConnection, httplib.HTTPSConnection):
  177
+            return False
  178
+        return True
  179
+
175 180
 
176 181
 send_request_app = SendRequest()

No commit comments for this range

Something went wrong with that request. Please try again.