Skip to content

Commit

Permalink
Fixed isolation of test_migrate_fake_split_initial.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixxm authored Dec 23, 2020
1 parent 8b2a30f commit ada83fd
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/migrations/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,20 @@ def test_migrate_fake_split_initial(self):
"""
Split initial migrations can be faked with --fake-initial.
"""
call_command("migrate", "migrations", "0002", verbosity=0)
call_command("migrate", "migrations", "zero", fake=True, verbosity=0)
out = io.StringIO()
with mock.patch('django.core.management.color.supports_color', lambda *args: False):
call_command("migrate", "migrations", "0002", fake_initial=True, stdout=out, verbosity=1)
value = out.getvalue().lower()
self.assertIn("migrations.0001_initial... faked", value)
self.assertIn("migrations.0002_second... faked", value)
# Fake an apply
call_command("migrate", "migrations", fake=True, verbosity=0)
# Unmigrate everything
call_command("migrate", "migrations", "zero", verbosity=0)
try:
call_command('migrate', 'migrations', '0002', verbosity=0)
call_command('migrate', 'migrations', 'zero', fake=True, verbosity=0)
out = io.StringIO()
with mock.patch('django.core.management.color.supports_color', lambda *args: False):
call_command('migrate', 'migrations', '0002', fake_initial=True, stdout=out, verbosity=1)
value = out.getvalue().lower()
self.assertIn('migrations.0001_initial... faked', value)
self.assertIn('migrations.0002_second... faked', value)
finally:
# Fake an apply.
call_command('migrate', 'migrations', fake=True, verbosity=0)
# Unmigrate everything.
call_command('migrate', 'migrations', 'zero', verbosity=0)

@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_conflict"})
def test_migrate_conflict_exit(self):
Expand Down

0 comments on commit ada83fd

Please sign in to comment.