Improved isolation of applied-migrations table in migration tests.

This commit is contained in:
Carl Meyer 2015-06-02 14:19:23 -06:00
parent 23048d186c
commit 335fc44f68
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from importlib import import_module
from django.apps import apps from django.apps import apps
from django.db import connection from django.db import connection
from django.db.migrations.recorder import MigrationRecorder
from django.test import TransactionTestCase from django.test import TransactionTestCase
from django.test.utils import extend_sys_path from django.test.utils import extend_sys_path
from django.utils.module_loading import module_dir from django.utils.module_loading import module_dir
@ -18,6 +19,11 @@ class MigrationTestBase(TransactionTestCase):
available_apps = ["migrations"] available_apps = ["migrations"]
def tearDown(self):
# Reset applied-migrations state.
recorder = MigrationRecorder(connection)
recorder.migration_qs.filter(app='migrations').delete()
def get_table_description(self, table): def get_table_description(self, table):
with connection.cursor() as cursor: with connection.cursor() as cursor:
return connection.introspection.get_table_description(cursor, table) return connection.introspection.get_table_description(cursor, table)