It strikes me that TransactionTestCase should be flushing the database
in the teardown stage of the test case rather than the setup. My
thinking is that when using a mixture of TestCase and
TransactionTestCase (where the latter is only used when testing
transaction-related behaviour) what's important is that the test db is
left in the 'clean' state at the end of the test. Otherwise subsequent
TestCase tests will be operating on a test db with any modifications
made by the TransactionTestCase test still in place, and thus
potentially failing.
So am I missing something or should this be changed?
Sean
--
Sean Legassick
sean.le...@gmail.com
> It strikes me that TransactionTestCase should be flushing the database
> in the teardown stage of the test case rather than the setup. My
> thinking is that when using a mixture of TestCase and
> TransactionTestCase (where the latter is only used when testing
> transaction-related behaviour) what's important is that the test db is
> left in the 'clean' state at the end of the test. Otherwise subsequent
> TestCase tests will be operating on a test db with any modifications
> made by the TransactionTestCase test still in place, and thus
> potentially failing.
>
> So am I missing something or should this be changed?
>
> Sean
As someone who's managed to hard-crash the Python interpreter while
building tests for the test suite, they most definitely should be in
the setup phase. It's the only way to ensure that right before your
test starts, no matter what horrible things happened previously, your
test DB will stay intact.
If there's a need for end cleaning as well, I don't know. I'll let
someone smarter than I speak to that.
George
I sort of see what you mean by that, but bear in mind that all the
flush stage does is truncate most of the tables, so you could still
theoretically do damage to your database prior to running tests that
this wouldn't undo (such as changing table structures or altering the
content types data). Obviously it will help if by 'horrible things'
you mean inserting broken or unwanted data into your model tables, but
it strikes me that the solution to that is to fix the code that's
doing it!
--
Sean Legassick
sean.le...@gmail.com
Ah, so that's what I was missing. That does ring a bell now you
mention it, I was reading some of your discussion of this at the time.
> Are you actually seeing TestCases run after TransactionTestCases?
I am seeing this, however I am using the GIS test runner which doesn't
have the reordering code.
So the correct solution instead of what I suggested is for me to work
up a patch for the GIS test runner that uses your reordering code.
Thanks,
Sean
(PS I've hit another issue with the new-style TestCase to do with
using the transaction decorators, but I'm more confident that I know
what's going on with that so I'm preparing a ticket about it with a
patch right now).
--
Sean Legassick
sean.le...@gmail.com