diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_request.py | 4 | ||||
| -rw-r--r-- | tests/test_response.py | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/tests/test_request.py b/tests/test_request.py index 016bd0e..462dc0f 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -797,7 +797,7 @@ class BaseRequestTests(unittest.TestCase): def test_path_info_pop_non_empty_w_pattern_miss(self): import re - PATTERN = re.compile('miss') + PATTERN = re.compile(b'miss') environ = {'wsgi.url_scheme': 'http', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '80', @@ -812,7 +812,7 @@ class BaseRequestTests(unittest.TestCase): def test_path_info_pop_non_empty_w_pattern_hit(self): import re - PATTERN = re.compile('path') + PATTERN = re.compile(b'path') environ = {'wsgi.url_scheme': 'http', 'SERVER_NAME': 'example.com', 'SERVER_PORT': '80', diff --git a/tests/test_response.py b/tests/test_response.py index 792d77d..8cef916 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -997,11 +997,30 @@ def test_decode_content_gzip(): def test__abs_headerlist_location_with_scheme(): res = Response() - res.content_encoding = 'gzip' res.headerlist = [('Location', 'http:')] result = res._abs_headerlist({}) eq_(result, [('Location', 'http:')]) +def test__abs_headerlist_location_with_relative(): + encoded_path_info = b'/\xe6\xb5\x81' + encoded_script_name = b'/\xe6\xb5\x82' + if PY3: + wsgiencoded_path_info = encoded_path_info.decode('latin-1') + wsgiencoded_script_name = encoded_script_name.decode('latin-1') + else: + wsgiencoded_path_info = encoded_path_info + wsgiencoded_script_name = encoded_script_name + environ = { + 'wsgi.url_scheme': 'http', + 'HTTP_HOST': 'test.com', + 'SCRIPT_NAME': wsgiencoded_script_name, + 'PATH_INFO': wsgiencoded_path_info, + } + res = Response() + res.headerlist = [('Location', 'foo')] + result = res._abs_headerlist(environ) + eq_(result, [('Location', 'http://test.com/%E6%B5%82/%E6%B5%81/foo')]) + def test_response_set_body_file1(): data = b'abc' file = io.BytesIO(data) |
