Reputation: 27855
I use pytest-django and the uncaught exception is unfortunately hidden
@pytest.mark.django_db
def test_foo(client):
url = reverse('foo')
response = client.get(url)
assert response.status_code == 200
I get:
E assert 500 == 200
Assertion failed
How can I configure pytest to show the real exception (and not the http 500 response)?
Upvotes: 0
Views: 34
Reputation: 14226
Since pytest
uses assert
statements for its tests we can take advantage of the extended form of the assert
statement as shown here.
In your case it would look like:
@pytest.mark.django_db
def test_foo(client):
url = reverse('foo')
response = client.get(url)
assert response.status_code == 200, response.exception_reason
The syntax for retrieving the Exception
in your case might be slightly different but hopefully you understand what needs to be changed.
Upvotes: 1