mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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>
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user