From 563d6572f3620dc33bb9c0bbfca63a73061087cc Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Tue, 20 Sep 2016 10:21:14 -0600 Subject: [PATCH] reverting 3357 and comparing properly encoded strings --- tests/test_requests.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/test_requests.py b/tests/test_requests.py index cc621a20..4ecef396 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -1070,18 +1070,13 @@ class TestRequests: # check raise_status falls back to ISO-8859-1 r = requests.Response() r.url = 'some url' - reason = b'Komponenttia ei l\xf6ydy' - r.reason = reason + reason = u'Komponenttia ei löydy' + r.reason = reason.encode('latin-1') r.status_code = 500 r.encoding = None - str_error = '' - try: + with pytest.raises(requests.exceptions.HTTPError) as e: r.raise_for_status() - except requests.exceptions.HTTPError as e: - str_error = e.args[0] - else: - raise AssertionError('Expected an HTTPError but it was not raised') - assert reason.decode('latin-1') in str_error + assert reason in e.value.args[0] def test_response_chunk_size_type(self): """Ensure that chunk_size is passed as None or an integer, otherwise