Created
June 3, 2016 13:44
-
-
Save davidszotten/56cb4583c00b7f694aa52796817e6450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management import call_command | |
from django.core.management.commands.makemigrations import Command | |
from django.db.migrations.writer import MigrationWriter | |
import mock | |
import pytest | |
def test_migrations_up_to_date(): | |
# --exit exits if there are _no_ changes, which is what we are looking for | |
with pytest.raises(SystemExit): | |
with mock.patch.object(Command, 'write_migration_files') as write: | |
call_command('makemigrations', dry_run=True, exit=True) | |
# output the actual migration contents for easier fixing | |
(changes,), _ = write.call_args | |
for app_label, app_migrations in changes.items(): | |
print "Migrations for '%s':\n" % app_label | |
for migration in app_migrations: | |
writer = MigrationWriter(migration) | |
print writer.as_string() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment