Test client raises UnboundLocalError when view raises exception and 500.html does not exist.
|Reported by:||ryan_freckleton||Owned by:||nobody|
|Severity:||Keywords:||test client exception unboundlocalerror|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If an exception is raised in a view that is requested by the test client and the 500.html template does not exist, the test fails with the following traceback:
Traceback (most recent call last): File "/home/ryan/src/django_stuff/client_test/../client_test/test_app/tests.py", line 5, in test response = self.client.get('/') File "/home/ryan/src/django_stuff/django_py/lib/python2.5/site-packages/django/test/client.py", line 265, in get return self.request(**r) File "/home/ryan/src/django_stuff/django_py/lib/python2.5/site-packages/django/test/client.py", line 231, in request response.client = self UnboundLocalError: local variable 'response' referenced before assignment
The view function used to generate this was:
def raise_error(request): raise Exception()
self.exc_info in the client is not set, so no exception is raised at line client.py:225-228, and an UnboundLocalError is raised at line 231.
This could possibly be related to issue #8136, but I'm not really sure.
Change History (6)
comment:1 Changed 8 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:4 Changed 8 years ago by russellm
- Resolution set to duplicate
- Status changed from new to closed