Opened 8 years ago

Closed 8 years ago

#27012 closed Bug (fixed)

test_nested_requests wipes out pre-test settings

Reported by: Chris Jerdonek Owned by: Chris Jerdonek
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Chris Jerdonek)

I noticed that nested_view() calls setup_test_environment() (direct link):

def nested_view(request):
    setup_test_environment()
    c = Client()
    c.get("/no_template_view/")
    return render(request, 'base.html', {'nested': 'yes'})

This function is used in the test: test_client_regress.tests.ContextTests.test_nested_requests.

This causes pre-test setting values like _original_email_backend and _original_allowed_hosts to be wiped out because these values are overwritten by the test values when setup_test_environment() is called a second time (see here for setup_test_environment()).

Change History (5)

comment:1 by Chris Jerdonek, 8 years ago

Description: modified (diff)

comment:2 by Chris Jerdonek, 8 years ago

Owner: changed from nobody to Chris Jerdonek
Status: newassigned

comment:3 by Chris Jerdonek, 8 years ago

Has patch: set

I added a pull request for this here.

comment:4 by Claude Paroz, 8 years ago

Triage Stage: UnreviewedReady for checkin
Version: 1.9master

Agreed, that could be the source of subtle bugs.

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 7bc5274f:

Fixed #27012 -- Removed unnecessary setup_test_environment() in a test.

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