I don't know about the nose, but here's how to work against the existing db with django modules (1.6).
from django.test.runner import DiscoverRunner from django.db import transaction class ExistingDBTestRunner(DiscoverRunner): def run_tests(self, test_labels, extra_tests=None, **kwargs): self.setup_test_environment() suite = self.build_suite(test_labels, extra_tests)
Then in settings.py
if 'test' in sys.argv: TEST_RUNNER = '<?>.ExistingDBTestRunner'
In earlier versions of django, it will be slightly different. In addition, you may need to override _fixture_setup and _fixture_teardown in your test cases.
The above code will connect to the existing database, but since each test is wrapped in a transaction, the changes will not be available to other connections (for example, a celery employee). The easiest way to disable transactions is to subclass from unittest.TestCase instead of django.test.TestCase .
source share