|
@@ -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):
|
|
|
"""
|