From 335fc44f6872f4678e48f65e91961ef19d6439b4 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Tue, 2 Jun 2015 14:19:23 -0600 Subject: [PATCH] Improved isolation of applied-migrations table in migration tests. --- tests/migrations/test_base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py index dc9b81411a..9ad637e8d1 100644 --- a/tests/migrations/test_base.py +++ b/tests/migrations/test_base.py @@ -6,6 +6,7 @@ from importlib import import_module from django.apps import apps from django.db import connection +from django.db.migrations.recorder import MigrationRecorder from django.test import TransactionTestCase from django.test.utils import extend_sys_path from django.utils.module_loading import module_dir @@ -18,6 +19,11 @@ class MigrationTestBase(TransactionTestCase): 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): with connection.cursor() as cursor: return connection.introspection.get_table_description(cursor, table)