summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_commands.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index 387cef924a..a9c1cdf893 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -2392,20 +2392,35 @@ class MakeMigrationsTests(MigrationTestBase):
"makemigrations", "migrations", "--name", "invalid name", "--empty"
)
- def test_makemigrations_check(self):
+ def test_makemigrations_check_with_changes(self):
"""
makemigrations --check should exit with a non-zero status when
there are changes to an app requiring migrations.
"""
+ out = io.StringIO()
with self.temporary_migration_module() as tmpdir:
- with self.assertRaises(SystemExit):
- call_command("makemigrations", "--check", "migrations", verbosity=0)
- self.assertFalse(os.path.exists(tmpdir))
+ with self.assertRaises(SystemExit) as cm:
+ call_command(
+ "makemigrations",
+ "--check",
+ "migrations",
+ stdout=out,
+ )
+ self.assertEqual(os.listdir(tmpdir), ["__init__.py"])
+ self.assertEqual(cm.exception.code, 1)
+ self.assertIn("Migrations for 'migrations':", out.getvalue())
+ def test_makemigrations_check_no_changes(self):
+ """
+ makemigrations --check should exit with a zero status when there are no
+ changes.
+ """
+ out = io.StringIO()
with self.temporary_migration_module(
module="migrations.test_migrations_no_changes"
):
- call_command("makemigrations", "--check", "migrations", verbosity=0)
+ call_command("makemigrations", "--check", "migrations", stdout=out)
+ self.assertEqual("No changes detected in app 'migrations'\n", out.getvalue())
def test_makemigrations_migration_path_output(self):
"""