From 232bb17d6f481e597624d7aa3b019bb32f26bd38 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 30 Nov 2012 14:16:57 -0600 Subject: [PATCH] Fix test_app to run in Python 3 --HG-- branch : py3k --- src/milla/tests/test_app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/milla/tests/test_app.py b/src/milla/tests/test_app.py index 15a72d0..3238cff 100644 --- a/src/milla/tests/test_app.py +++ b/src/milla/tests/test_app.py @@ -33,7 +33,7 @@ class ResponseMaker(object): def __init__(self, http_version=1.1): self.http_version = http_version self.headers = '' - self.body = '' + self.body = b'' def start_response(self, status, response_headers): self.headers += 'HTTP/{0} {1}\r\n'.format(self.http_version, status) @@ -78,7 +78,7 @@ def test_favicon(): app_iter = app(environ, response.start_response) response.finish_response(app_iter) assert response.headers.startswith('HTTP/1.1 200'), response.headers - assert response.body.startswith('\x00\x00\x01\x00'), response.body + assert response.body.startswith(b'\x00\x00\x01\x00'), response.body def test_allow_header_disallowed(): '''HTTP 405 is returned for disallowed HTTP request methods @@ -138,7 +138,7 @@ def test_emulated_method(): }) body = environ['wsgi.input'] body.seek(0) - body.write('_method=PUT') + body.write(b'_method=PUT') body.seek(0) response = ResponseMaker() app_iter = app(environ, response.start_response) @@ -358,7 +358,7 @@ def test_httperror_response(): ''' def controller(request): - raise webob.exc.HTTPClientError() + raise webob.exc.HTTPClientError('NotFound') app = milla.app.Application(StubResolver(controller)) environ = testing_environ() @@ -366,7 +366,7 @@ def test_httperror_response(): app_iter = app(environ, response.start_response) response.finish_response(app_iter) assert response.headers.startswith('HTTP/1.1 400'), response.headers - assert webob.exc.HTTPClientError.explanation in response.body, response.body + assert b'NotFound' in response.body, response.body def test_single_start_response(): '''Ensure start_response is only called once''' @@ -393,4 +393,4 @@ def test_single_start_response(): response.finish_response(app_iter) assert start_response.call_count == 1, start_response.call_count assert response.headers.startswith('HTTP/1.1 200 OK'), response.headers - assert response.body == 'test', response.body + assert response.body == b'test', response.body