django-test-without-migrations
raw JSON → 0.6 verified Fri May 01 auth: no python
Disables Django migrations when running tests, significantly speeding up test runs by using the current model state instead of running migrations. Version 0.6 is the latest, with no recent updates. Use it to avoid migration overhead in CI or local testing.
pip install django-test-without-migrations Common errors
error ImportError: cannot import name 'DjangoTestSuiteRunner' ↓
cause Using an incorrect import path or the package is not installed.
fix
Install the package: pip install django-test-without-migrations. Then use: from django_test_without_migrations import DjangoTestSuiteRunner
error AttributeError: 'DjangoTestSuiteRunner' object has no attribute 'setup_databases' ↓
cause The test runner class has been misconfigured or an incorrect version of Django is used.
fix
Ensure you are using Django <= 1.10 for the TEST_RUNNER approach, or switch to the mixin pattern for later Django versions.
error django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: ... ↓
cause Using TEST_RUNNER with a test database that has existing tables from migrations, causing conflict.
fix
Clear the test database or use the mixin pattern which creates tables from models without migrations.
Warnings
gotcha Disabling migrations means tables are created directly from models. Ensure your models match the expected schema, as any missing migrations (like field additions) will not be applied. This can mask migration bugs. ↓
fix Run tests with migrations periodically (e.g., on CI) to catch migration issues.
deprecated Django 1.10+ deprecates the pattern of overriding TEST_RUNNER with a custom runner. The mixin approach is recommended for newer Django versions. ↓
fix Use the mixin 'TestWithoutMigrationsMixin' instead of setting TEST_RUNNER if using Django 1.10+.
gotcha If you have multiple databases, the TEST_RUNNER may not handle them correctly. You might need to extend the runner to support additional database aliases. ↓
fix Write a custom test runner that inherits from DjangoTestSuiteRunner and overrides setup_databases.
Imports
- TestWithoutMigrationsMixin
from django_test_without_migrations import TestWithoutMigrationsMixin
Quickstart
# settings.py
TEST_RUNNER = 'django_test_without_migrations.DjangoTestSuiteRunner'
# Or use as a mixin in a test class:
from django.test import TestCase
from django_test_without_migrations import TestWithoutMigrationsMixin
class MyTestCase(TestWithoutMigrationsMixin, TestCase):
def test_something(self):
self.assertTrue(True)