If you use django.test.TestCase to write your tests, most of the time you'll be preparing model instances in your
from django.utils import unittest
from myapp.models import Animal
self.lion = Animal(name="lion", sound="roar")
self.cat = Animal(name="cat", sound="meow")
"""Animals that can speak are correctly identified"""
self.assertEqual(self.lion.speak(), 'The lion says "roar"')
self.assertEqual(self.cat.speak(), 'The cat says "meow"')
As your test cases grow, they take more and more time to run, partly because at the start of each test, before
setUp() is run, Django will flush the database, returning the database to the state it was in directly after syncdb was called.
You can save some time using a class method instead:
cls.lion = Animal(name="lion", sound="roar")
cls.cat = Animal(name="cat", sound="meow")
Doing so will create the objects once per test case, speeding up your tests.