summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-23 10:06:08 +0200
committerGitHub <noreply@github.com>2021-04-23 10:06:08 +0200
commit2f435e75ab4923c50f0999a77dfc26cff4429deb (patch)
treea141ed309cfac2f0998fdd7ca07957518b8d0c7e
parentac2e6e686906810e9c24ca6c39cae6234ab25557 (diff)
Fixed isolation of test_showmigrations_unmigrated_app().
Follow up to 90916f050c64b817fdf2ea13b5c20986005fd029.
-rw-r--r--tests/migrations/test_commands.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index 00d4de1ff1..b253192a56 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -670,7 +670,15 @@ class MigrateTests(MigrationTestBase):
def test_showmigrations_plan_app_label_no_migrations(self):
out = io.StringIO()
call_command('showmigrations', 'unmigrated_app', format='plan', stdout=out, no_color=True)
- self.assertEqual('(no migrations)\n', out.getvalue())
+ try:
+ self.assertEqual('(no migrations)\n', out.getvalue())
+ finally:
+ # unmigrated_app.SillyModel has a foreign key to
+ # 'migrations.Tribble', but that model is only defined in a
+ # migration, so the global app registry never sees it and the
+ # reference is left dangling. Remove it to avoid problems in
+ # subsequent tests.
+ apps._pending_operations.pop(('migrations', 'tribble'), None)
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
def test_sqlmigrate_forwards(self):