diff options
| author | David Smith <smithdc@gmail.com> | 2020-11-07 20:57:17 +0000 |
|---|---|---|
| committer | David Smith <smithdc@gmail.com> | 2020-11-07 20:57:17 +0000 |
| commit | d5df159bd27b41c77042e8814ab4f37ebdcea18a (patch) | |
| tree | ebdbc51934f9546d43e3f172e376e43489f0c72c /webtest/http.py | |
| parent | 3d09494d80713a32d9bc52e457bff16fb6ba285c (diff) | |
| download | webtest-d5df159bd27b41c77042e8814ab4f37ebdcea18a.tar.gz | |
Dropped support for Python 2.7 and 3.5
Diffstat (limited to 'webtest/http.py')
| -rw-r--r-- | webtest/http.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/webtest/http.py b/webtest/http.py index 890ef96..efe4ace 100644 --- a/webtest/http.py +++ b/webtest/http.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ This module contains some helpers to deal with the real http world. @@ -11,9 +10,9 @@ import socket import time import os -import six +from http import client + import webob -from six.moves import http_client from waitress.server import TcpWSGIServer @@ -33,11 +32,11 @@ def check_server(host, port, path_info='/', timeout=3, retries=30): time.sleep(.3) for i in range(retries): try: - conn = http_client.HTTPConnection(host, int(port), timeout=timeout) + conn = client.HTTPConnection(host, int(port), timeout=timeout) conn.request('GET', path_info) res = conn.getresponse() return res.status - except (socket.error, http_client.HTTPException): + except (OSError, client.HTTPException): time.sleep(.3) return 0 @@ -53,7 +52,7 @@ class StopableWSGIServer(TcpWSGIServer): was_shutdown = False def __init__(self, application, *args, **kwargs): - super(StopableWSGIServer, self).__init__(self.wrapper, *args, **kwargs) + super().__init__(self.wrapper, *args, **kwargs) self.runner = None self.test_app = application self.application_url = 'http://%s:%s/' % (self.adj.host, self.adj.port) @@ -72,8 +71,8 @@ class StopableWSGIServer(TcpWSGIServer): filename = req.params.get('__file__') if os.path.isfile(filename): body = open(filename, 'rb').read() - body = body.replace(six.b('http://localhost/'), - six.b('http://%s/' % req.host)) + body = body.replace(b'http://localhost/', + bytes('http://%s/' % req.host, 'UTF-8')) resp.body = body else: resp.status = '404 Not Found' @@ -86,7 +85,7 @@ class StopableWSGIServer(TcpWSGIServer): """Run the server""" try: self.asyncore.loop(.5, map=self._map) - except select.error: # pragma: no cover + except OSError: # pragma: no cover if not self.was_shutdown: raise |
