Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Is it necessary to impliment tearDown to clean up database when using django.test.TestCase? [RSS Feed]

#1 March 7, 2008 18:22:49

m.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Is it necessary to impliment tearDown to clean up database when using django.test.TestCase?


I've been doing something like the following:

MODELS =

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?

-Meppum
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

#2 March 9, 2008 13:45:34

Kent J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Is it necessary to impliment tearDown to clean up database when using django.test.TestCase?


meppum wrote:
> I've been doing something like the following:
>
> MODELS =
>
> 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?

Using unittest.TestCase I do this in setUp(), rather than tearDown, so I
know the test starts with a clean table.

Kent

--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

  • Root
  • » Django
  • » Is it necessary to impliment tearDown to clean up database when using django.test.TestCase? [RSS Feed]

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support