diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2021-08-06 09:17:13 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-10-12 15:19:39 +0200 |
| commit | 32f1fe5f89bc9ae98161c07f3676f6aaedc8e877 (patch) | |
| tree | cea3542a8fac71cd0e3a2c43e01b0c42362a7e39 /tests | |
| parent | 241ba23870221085cc31ae302b9647f375f9c6c6 (diff) | |
Fixed #29470 -- Logged makemigrations automatic decisions in non-interactive mode.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 3e76332630..7b173c68bc 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1361,7 +1361,14 @@ class MakeMigrationsTests(MigrationTestBase): with self.assertRaises(SystemExit): with self.temporary_migration_module(module="migrations.test_migrations_no_default"): - call_command("makemigrations", "migrations", interactive=False) + with captured_stdout() as out: + call_command('makemigrations', 'migrations', interactive=False) + self.assertIn( + "Field 'silly_int' on model 'sillymodel' not migrated: it is " + "impossible to add a non-nullable field without specifying a " + "default.", + out.getvalue(), + ) def test_makemigrations_interactive_not_null_addition(self): """ @@ -1417,10 +1424,15 @@ class MakeMigrationsTests(MigrationTestBase): class Meta: app_label = "migrations" - out = io.StringIO() with self.temporary_migration_module(module="migrations.test_migrations"): - call_command("makemigrations", "migrations", interactive=False, stdout=out) + with captured_stdout() as out: + call_command('makemigrations', 'migrations', interactive=False) self.assertIn("Alter field slug on author", out.getvalue()) + self.assertIn( + "Field 'slug' on model 'author' given a default of NOT PROVIDED " + "and must be corrected.", + out.getvalue(), + ) def test_makemigrations_interactive_not_null_alteration(self): """ @@ -1884,8 +1896,14 @@ class MakeMigrationsTests(MigrationTestBase): app_label = 'migrations' with self.temporary_migration_module(module='migrations.test_auto_now_add'): - with self.assertRaises(SystemExit): + with self.assertRaises(SystemExit), captured_stdout() as out: call_command('makemigrations', 'migrations', interactive=False) + self.assertIn( + "Field 'creation_date' on model 'entry' not migrated: it is " + "impossible to add a field with 'auto_now_add=True' without " + "specifying a default.", + out.getvalue(), + ) def test_makemigrations_interactive_unique_callable_default_addition(self): """ |
