summaryrefslogtreecommitdiff
path: root/webtest/debugapp.py
diff options
context:
space:
mode:
authorGael Pasgrimaud <gael@gawel.org>2011-08-25 23:12:53 +0200
committerGael Pasgrimaud <gael@gawel.org>2011-08-25 23:12:53 +0200
commit8a07dddbd9704631640d979e67a2ee3767122943 (patch)
treeaedfe9cdae7ab3bc4d746f8f7ca207ae981ee0c2 /webtest/debugapp.py
parent87d90402e5b4bbb878eee735d1b12b39e72f574c (diff)
downloadwebtest-8a07dddbd9704631640d979e67a2ee3767122943.tar.gz
py3 compat. only 4 errors remaining
Diffstat (limited to 'webtest/debugapp.py')
-rw-r--r--webtest/debugapp.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/webtest/debugapp.py b/webtest/debugapp.py
index abc119d..c91241e 100644
--- a/webtest/debugapp.py
+++ b/webtest/debugapp.py
@@ -1,20 +1,18 @@
from webob import Request, Response
-try:
- sorted
-except NameError:
- from webtest import sorted
+from webtest.compat import to_bytes
__all__ = ['debug_app']
+
def debug_app(environ, start_response):
req = Request(environ)
if req.path_info == '/form.html' and req.method == 'GET':
resp = Response(content_type='text/html')
- resp.body = '''<html><body>
+ resp.body = to_bytes('''<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>''')
return resp(environ, start_response)
if 'error' in req.GET:
@@ -32,12 +30,12 @@ def debug_app(environ, start_response):
else:
req_body = ''
if req_body:
- parts.append('-- Body ----------\n')
+ parts.append(to_bytes('-- Body ----------\n'))
parts.append(req_body)
- body = ''.join(parts)
+ body = to_bytes('').join([to_bytes(p) for p in parts])
if status[:3] in ('204', '304') and not req_body:
- body = ''
+ body = to_bytes('')
headers = [
('Content-Type', 'text/plain'),
@@ -48,9 +46,9 @@ def debug_app(environ, start_response):
header_name = name[len('header-'):]
headers.append((header_name, value))
- start_response(status, headers)
+ start_response(to_bytes(str(status)), headers)
if req.method == 'HEAD':
- return ['']
+ return [to_bytes('')]
return [body]
def make_debug_app(global_conf):