On Thu, Jun 25, 2009 at 08:29:56AM +0100, Chris Withers wrote:
> I'm wondering what the common idiom is for unit testing w.r.t. data and
> transactions...
...
> How do I get test data needed for a specific test to exist for only that
> test?

Create the data in the corresponding setUp, and then clean it up in the
tearDown, I guess.

> How do I abort changes made by a test in a unittest.TestCase sublcasses
> tearDown method?

What I ended up doing was clearing out the tables modified by the test
and re-running the initialization code from websetup.py.  It was
expensive (perhaps 600 ms) but worked fine.

I believe there are libraries out there for managing SQL database test
fixtures.  I'm not personally familiar with any of them.

Marius Gedminas
-- 
Go not unto the Usenet for advice, for you will be told both yea and nay (and
quite a few things that just have nothing at all to do with the question).

Attachment: signature.asc
Description: Digital signature

Reply via email to