summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2023-11-08 22:29:07 +0000
committerNatalia <124304+nessita@users.noreply.github.com>2023-11-09 10:03:19 -0300
commitf7389c4b07ceeb036436e065898e411b247bca78 (patch)
tree0fcf82ebb0f5dc5776747a60031a220b3d4875de /tests/migrations
parent427f0ed98d7ecf4381cebd4f7773f761e2446851 (diff)
Fixed #34457 -- Restored output for makemigrations --check.
Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Diffstat (limited to 'tests/migrations')
-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):
"""