Opened 9 years ago
Closed 9 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 , 9 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 9 years ago
| Has patch: | set |
|---|
comment:3 by , 9 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Cleanup/optimization |
I posted a pull request for this here.