Opened 13 years ago
Closed 12 years ago
#18271 closed Cleanup/optimization (fixed)
Make TransactionTestCase flush tables after test run instead of before
Reported by: | Andreas Pelme | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
TransactionTestCase does not clean up after a test is run. When the next TransactionTestCase is run, tables are flushed and fixtures are loaded.
It would be better if the flush took place in _post_teardown, which would leave the database in a clean state after each test. Then test order does not matter, TransactionTestCase and TestCases can be executed in arbitrary order.
There is a related ticket #12408 to reorder doctests to also run before TransactionTestCase. If TransactionTestCase is changed, no reordering will be necessary.
django-developers discussion: http://groups.google.com/group/django-developers/browse_thread/thread/3df2b4926eba08d2?hl=en
Change History (3)
comment:2 by , 13 years ago
Component: | Uncategorized → Testing framework |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
I am going to mark this design decision needed. I do think this is a good idea, but there are two problems:
- If a test case screws up cleanup it will cause problems for itself currently, after the patch it will cause problems for the next test case which makes debugging much harder.
- Is this somehow backwards incompatible. The behavior was documented.
I think neither of the above is a blocker issue. The first issue can be annoying, but is is pretty much there already - if the cleanup doesn't work correctly, the breakage will be dependent on the previous test case anyways. I can't come up with any reason why moving the flush from before to after would be an issue... The backwards compatibility does need more investigation, though.
The main reason why I am marking this DDN is that maybe there was some reason why the flush was ran before the tests. So, lets keep this in DDN until everybody has had time to participate in the django-developers thread. If there are no objections in a week or so I am fine with moving this forward.
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Initial patch is available as a pull request:
https://github.com/django/django/pull/45