Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8358 closed (fixed)

Test client raises UnboundLocalError when view raises exception and 500.html does not exist.

Reported by: Ryan Freckleton Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords: test client exception unboundlocalerror
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 by Russell Keith-Magee, 16 years ago

Triage Stage: UnreviewedAccepted

This could be the same cause as #8136, but the reported exception is slightly different; I'll make sure when I get around to fixing the problem.

comment:2 by Russell Keith-Magee, 16 years ago

Component: Core frameworkUnit test system

comment:3 by Ryan Freckleton, 16 years ago

I tried the patch associated with #8136 and it seems to fix this error message as well. So it's probably the same root cause.

comment:4 by Russell Keith-Magee, 16 years ago

Resolution: duplicate
Status: newclosed

On deeper inspection, this is the same problem as #8136.

comment:5 by Jacob, 15 years ago

Resolution: duplicatefixed

(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

comment:18 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top