On Sat, Mar 8, 2008 at 3:22 AM, meppum <[EMAIL PROTECTED]> wrote: > > I've been doing something like the following: > > MODELS = [SomeObjectType, AnotherObjectType] > > class testFoo(TestCase): > > def tearDown(self): > for model in MODELS: > model.objecs.all().delete() > > Is this how tests should be created, or is all this done behind the > scenes when using TestCase?
Depends on which TestCase you are using, and the combinations in which you are using them. django.test.TestCase does a full database flush at the start of each new test. This means that you don't need to manually delete objects in tearDown - the next test setUp will make sure the database is clean. doctests and unittest.TestCase do no database preparations. At the start of a test, the database will be in whatever state the previous test left. This could mean some stray data which could cause testing conflicts if you are not careful, so a cleanup might be good practice. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---