Fixed #23728 -- Added the --exit option to makemigrations.

If no changes that need migrations are found, `makemigrations --exit`
exits with error code 1.
This commit is contained in:
Tim Heap 2014-11-11 15:41:55 +11:00 committed by Tim Graham
parent ab89414f40
commit deb607648e
5 changed files with 40 additions and 8 deletions

View file

@ -543,6 +543,18 @@ class MakeMigrationsTests(MigrationTestBase):
self.assertIn("dependencies=[\n('migrations','0001_%s'),\n]" % migration_name_0001, content)
self.assertIn("operations=[\n]", content)
def test_makemigrations_exit(self):
"""
makemigrations --exit should exit with sys.exit(1) when there are no
changes to an app.
"""
with self.settings(MIGRATION_MODULES={"migrations": self.migration_pkg}):
call_command("makemigrations", "--exit", "migrations", verbosity=0)
with self.settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_no_changes"}):
with self.assertRaises(SystemExit):
call_command("makemigrations", "--exit", "migrations", verbosity=0)
class SquashMigrationsTest(MigrationTestBase):
"""