Fixed isolation of test_showmigrations_unmigrated_app().

This commit is contained in:
Mariusz Felisiak 2021-04-22 17:43:58 +02:00 committed by GitHub
parent c3278bb71f
commit 90916f050c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -519,7 +519,15 @@ class MigrateTests(MigrationTestBase):
def test_showmigrations_unmigrated_app(self):
out = io.StringIO()
call_command('showmigrations', 'unmigrated_app', stdout=out, no_color=True)
self.assertEqual('unmigrated_app\n (no migrations)\n', out.getvalue().lower())
try:
self.assertEqual('unmigrated_app\n (no migrations)\n', out.getvalue().lower())
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_empty"})
def test_showmigrations_plan_no_migrations(self):
@ -836,7 +844,7 @@ class MigrateTests(MigrationTestBase):
# 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.
del apps._pending_operations[('migrations', 'tribble')]
apps._pending_operations.pop(('migrations', 'tribble'), None)
@override_settings(INSTALLED_APPS=['migrations.migrations_test_apps.unmigrated_app_syncdb'])
def test_migrate_syncdb_deferred_sql_executed_with_schemaeditor(self):