Skip to content

Commit

Permalink
Use pytest helper for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Aug 31, 2014
1 parent 811b438 commit 8377106
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/test_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ def test_serving(dev_server):
def test_broken_app(dev_server):
def broken_app(environ, start_response):
1 // 0

server, addr = dev_server(broken_app)
try:

with pytest.raises(HTTPError) as excinfo:
urlopen('http://%s/?foo=bar&baz=blah' % addr).read()
except HTTPError as e:
# In Python3 a 500 response causes an exception
rv = e.read()
assert b'Internal Server Error' in rv
else:
assert False, 'expected internal server error'

rv = excinfo.value.read()
assert b'Internal Server Error' in rv


def test_absolute_requests(dev_server):
Expand Down

0 comments on commit 8377106

Please sign in to comment.