From 33924a86493c70f9cfcfa4ff0f057fdaa1d77084 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 20 Mar 2016 07:52:13 +0200 Subject: [PATCH] Use more pytest.raises() in test_http.py Signed-off-by: Berker Peksag --- tests/test_http.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/test_http.py b/tests/test_http.py index 7b4761c8..49d42f3e 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -81,21 +81,16 @@ def test_http_header_encoding(): # set umlaut header response.headers.append(('foo', 'häder')) - try: + with pytest.raises(UnicodeEncodeError): response.send_headers() - except Exception as e: - assert isinstance(e, UnicodeEncodeError) - # build our own header_str to compare against tosend = response.default_headers() tosend.extend(["%s: %s\r\n" % (k, v) for k, v in response.headers]) header_str = "%s\r\n" % "".join(tosend) - try: + with pytest.raises(UnicodeEncodeError): mocked_socket.sendall(util.to_bytestring(header_str,"ascii")) - except Exception as e: - assert isinstance(e, UnicodeEncodeError) def test_http_inalid_response_header():