New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client: testing exceptions in views (client.store_exc_info) #130
Comments
Are you looking to silence that exception? Or catch it? Would you like that test to fail? |
I want to get the rendered content of the page, not the Exception (IndexError) from the view. It's related to this commit in Django: django/django@f9cdde0cb4 E.g.:
|
You are a hero for figuring this out. I've been struggling for hours trying to figure out how to test django-tastypie's canned_response, and the django test client interfered with the test (as I'm sure you know). Your solution completely solved the problem, thank you so much! You are awesome! Also, anyone who considers this interference by the test client to be a "feature" should be ashamed of themselves. |
I think a "fix" for this belongs in Django and in the test Client itself. I.e. initiating client objects with |
I want to test a view that throws an exception, and came up with the following code to make it work, so that the exception is not re-thrown by the client (code ref: https://github.com/django/django/blob/master/django/test/client.py#L421-443):
Given that it was not trivial to figure this out I wonder if this is the correct approach and if pytest-django could help in this regard (documentation, helper, ...)
I will look into providing a documentation update for Django itself, but want to get some feedback first.
The text was updated successfully, but these errors were encountered: