From deb607648ed7d484a90474b6da48642b4f39bca7 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Tue, 11 Nov 2014 15:41:55 +1100 Subject: Fixed #23728 -- Added the --exit option to makemigrations. If no changes that need migrations are found, `makemigrations --exit` exits with error code 1. --- tests/migrations/test_commands.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index ddbcfb343a..5995468e98 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -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): """ -- cgit v1.3