I am still using Django 1.2.1, and I think with the newer Django we don\'t import unittest
and then do unittest.TestCase
.
Illustration<
Django's TestCase
enhances unittest.TestCase
with some extra features:
Generally speaking, you should most likely be using one of Django's TestCase subclasses. Usually this will be django.test.TestCase
, which, for efficiency, wraps the test in a DB transaction and uses rollback to 'undo' the test in the DB. If you need to manually manage transactions within your test, you would need to use django.test.TransactionTestCase
, since you can't start / rollback a transaction within a transaction.
There are some minor caveats to using django.test.TestCase
, see the note here for more information.
ALSO:
If you're just looking for a way to run your tests faster, have a look at running your tests in memory, and (if you're using South), set SOUTH_TESTS_MIGRATE = False
to tell South to use a (much faster) syncdb
when creating the test DB, rather than running migrations.