diff options
Diffstat (limited to 'webtest/debugapp.py')
| -rw-r--r-- | webtest/debugapp.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/webtest/debugapp.py b/webtest/debugapp.py index dd05fbc..b7e8ddc 100644 --- a/webtest/debugapp.py +++ b/webtest/debugapp.py @@ -1,13 +1,12 @@ import os -import six import webob __all__ = ['DebugApp', 'make_debug_app'] -class DebugApp(object): +class DebugApp: """The WSGI application used for testing""" def __init__(self, form=None, show_form=False): @@ -31,8 +30,6 @@ class DebugApp(object): if 'errorlog' in req.GET: log = req.GET['errorlog'] - if not six.PY3 and not isinstance(log, six.binary_type): - log = log.encode('utf8') req.environ['wsgi.errors'].write(log) status = str(req.GET.get('status', '200 OK')) @@ -42,14 +39,14 @@ class DebugApp(object): for name, value in sorted(environ.items()): if name.upper() != name: value = repr(value) - parts.append(str('%s: %s\n') % (name, value)) + parts.append('%s: %s\n' % (name, value)) body = ''.join(parts) - if not isinstance(body, six.binary_type): + if not isinstance(body, bytes): body = body.encode('latin1') if req.content_length: - body += six.b('-- Body ----------\n') + body += b'-- Body ----------\n' body += req.body else: body = '' @@ -60,14 +57,14 @@ class DebugApp(object): body = '' headers = [ - ('Content-Type', str('text/plain')), + ('Content-Type', 'text/plain'), ('Content-Length', str(len(body)))] if not self.show_form: for name, value in req.GET.items(): if name.startswith('header-'): header_name = name[len('header-'):] - if isinstance(header_name, six.text_type): + if isinstance(header_name, str): header_name = str(header_name) header_name = header_name.title() headers.append((header_name, str(value))) @@ -76,18 +73,18 @@ class DebugApp(object): resp.status = status resp.headers.update(headers) if req.method != 'HEAD': - if isinstance(body, six.text_type): + if isinstance(body, str): resp.body = body.encode('utf8') else: resp.body = body return resp(environ, start_response) -debug_app = DebugApp(form=six.b('''<html><body> +debug_app = DebugApp(form=b'''<html><body> <form action="/form-submit" method="POST"> <input type="text" name="name"> <input type="submit" name="submit" value="Submit!"> -</form></body></html>''')) +</form></body></html>''') def make_debug_app(global_conf, **local_conf): |
