From c9a2100668259057956caeddda1bcda79f5b52bc Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 22 Apr 2015 00:48:57 +0200 Subject: Fix test_exceptions on Python 3 --- tests/test_exceptions/test_error_middleware.py | 8 +++++--- tests/test_exceptions/test_formatter.py | 1 - tests/test_exceptions/test_httpexceptions.py | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/test_exceptions/test_error_middleware.py b/tests/test_exceptions/test_error_middleware.py index d8fd802..95ab177 100644 --- a/tests/test_exceptions/test_error_middleware.py +++ b/tests/test_exceptions/test_error_middleware.py @@ -57,7 +57,7 @@ def after_start_response_app(environ, start_response): def iter_app(environ, start_response): start_response("200 OK", [('Content-type', 'text/plain')]) - return yielder(['this', ' is ', ' a', None]) + return yielder([b'this', b' is ', b' a', None]) def yielder(args): for arg in args: @@ -73,8 +73,10 @@ def test_makes_exception(): res = do_request(bad_app) assert '' in result[0] + assert b'' in result[0] assert "302 Found" == saved[0][0] - assert "text/html" == header_value(saved[0][1], 'content-type') + if six.PY3: + assert "text/html; charset=utf8" == header_value(saved[0][1], 'content-type') + else: + assert "text/html" == header_value(saved[0][1], 'content-type') assert "/bing/foo" == header_value(saved[0][1],'location') result = list(app({'HTTP_ACCEPT': 'text/plain'},saveit)) - print(result[0] == ( - '302 Found\n' - 'This resource was found at /bing/foo;\n' - 'you should be redirected automatically.\n')) assert "text/plain; charset=utf8" == header_value(saved[1][1],'content-type') assert "/bing/foo" == header_value(saved[1][1],'location') -- cgit v1.2.1