I am trying to run my Django test suite with an alternative test runner (py.test), and found some issues with test isolation.
TransactionTestCase does currently not clean up after itself (i.e. flush the database), but instead assumes that the next test will flush the database. It is generally a good idea to restore the state after the test run, and let other tests start out with a known state. Djangos default testrunner reorders the test suite to run all TestCase tests before TransactionTestCases, which avoids this problem. I cannot find this reordering documented anywhere, or even commented anywhere in the implementation (test/simple.py: reorder_suite and DjangoTestSuiteRunner.build_suite). I propose to move the flush command out of _fixture_setup to _post_teardown in TransactionTestCase. This makes it possible for arbitrary execution order of the test suite. Performance could potentially be an issue, since it is "lazy" today and flushes the database just right before it is needed. That would however only affect the last test in the run (i.e. it will truncate the tables, and then the database itself will be teared down). Are there any objections or anything that might break with such a change? Are there any specific reasons it works the way it does? I will be happy to create a ticket and patch for this, I would get to input in case I miss something obvious. Cheers Andreas -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
