Opened 8 years ago

Closed 8 years ago

#27032 closed Cleanup/optimization (fixed)

Calling setup_test_environment() "twice" deletes pre-setup state

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

Description

Currently, if django.test.utils.setup_test_environment() is called twice before calling teardown_test_environment(), then the saved, pre-setup state is lost, causing a subsequent call to teardown_test_environment() not to work as it should. This is because setup_test_environment() saves the current state to a single backup location that gets overwritten each time the function is called. See here for a link to the body of the function.

This behavior is somewhat subtle and could lead to hard-to-trackdown (or unnoticed) bugs.

I propose raising an exception if setup_test_environment() is called twice. This would have averted this issue, for example.

I started a pull request to do this here. However, I will create a new PR with an updated patch after this ticket is created (at which point I will have a ticket number to reference).

Change History (4)

comment:1 by Chris Jerdonek, 8 years ago

Owner: changed from nobody to Chris Jerdonek
Status: newassigned

comment:2 by Chris Jerdonek, 8 years ago

Has patch: set

I posted a pull request for this here.

comment:3 by Claude Paroz, 8 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

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

Resolution: fixed
Status: assignedclosed

In e7fb724c:

Fixed #27032 -- Prevented setup_test_environment() from being called twice.

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