diff options
| author | Moayad Mardini <moayad.m@gmail.com> | 2014-05-26 23:09:17 +0300 |
|---|---|---|
| committer | Moayad Mardini <moayad.m@gmail.com> | 2014-05-27 00:40:55 +0300 |
| commit | 2e613ea5c52d4d12e071987178af18c0371d6e2f (patch) | |
| tree | 830aa0eef0d7e5c5462bf7ab43aeff43eb9b60e6 /tests | |
| parent | b625e861e5d2709a16588ecb82f46e1fb86004c7 (diff) | |
Fixed #22675 -- makemigrations --dry-run to output migrations to stdout.
`makemigrations --dry-run` will output the complete migrations file
that would be written if it's used along with `--verbosity 3`.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 2f78ee27a4..4783ffa0c3 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -382,3 +382,34 @@ class MakeMigrationsTests(MigrationTestBase): call_command("makemigrations", "migrations", dry_run=True, stdout=stdout) # Output the expected changes directly, without asking for defaults self.assertIn("Add field silly_date to sillymodel", stdout.getvalue()) + + @override_system_checks([]) + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_no_default"}) + def test_makemigrations_dry_run_verbosity_3(self): + """ + Ticket #22675 -- Allow `makemigrations --dry-run` to output the + migrations file to stdout (with verbosity == 3). + """ + + class SillyModel(models.Model): + silly_field = models.BooleanField(default=False) + silly_char = models.CharField(default="") + + class Meta: + app_label = "migrations" + + stdout = six.StringIO() + call_command("makemigrations", "migrations", dry_run=True, stdout=stdout, verbosity=3) + + # Normal --dry-run output + self.assertIn("- Add field silly_char to sillymodel", stdout.getvalue()) + + # Additional output caused by verbosity 3 + # The complete migrations file that would be written + self.assertIn("# -*- coding: utf-8 -*-", stdout.getvalue()) + self.assertIn("class Migration(migrations.Migration):", stdout.getvalue()) + self.assertIn("dependencies = [", stdout.getvalue()) + self.assertIn("('migrations', '0001_initial'),", stdout.getvalue()) + self.assertIn("migrations.AddField(", stdout.getvalue()) + self.assertIn("model_name='sillymodel',", stdout.getvalue()) + self.assertIn("name='silly_char',", stdout.getvalue()) |
