diff options
| author | François Freitag <mail@franek.fr> | 2020-04-26 20:34:35 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-28 06:32:43 +0200 |
| commit | f19bb54fb1fcfdc9699c645d2de9dc99684bf5a1 (patch) | |
| tree | a9ddbff265c34c9f625bcbf2cd1c9ebf08bde0e1 | |
| parent | ca769c8c13df46b8153a0a4ab3d748e88d6e26f9 (diff) | |
Added test for squashmigrations' output.
| -rw-r--r-- | tests/migrations/test_commands.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 496cdb00cf..a0b33ca6f5 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1589,11 +1589,25 @@ class SquashMigrationsTests(MigrationTestBase): """ squashmigrations squashes migrations. """ + out = io.StringIO() with self.temporary_migration_module(module="migrations.test_migrations") as migration_dir: - call_command("squashmigrations", "migrations", "0002", interactive=False, verbosity=0) + call_command('squashmigrations', 'migrations', '0002', interactive=False, stdout=out, no_color=True) squashed_migration_file = os.path.join(migration_dir, "0001_squashed_0002_second.py") self.assertTrue(os.path.exists(squashed_migration_file)) + self.assertEqual( + out.getvalue(), + 'Will squash the following migrations:\n' + ' - 0001_initial\n' + ' - 0002_second\n' + 'Optimizing...\n' + ' Optimized from 8 operations to 2 operations.\n' + 'Created new squashed migration %s\n' + ' You should commit this migration but leave the old ones in place;\n' + ' the new migration will be used for new installs. Once you are sure\n' + ' all instances of the codebase have applied the migrations you squashed,\n' + ' you can delete them.\n' % squashed_migration_file + ) def test_squashmigrations_initial_attribute(self): with self.temporary_migration_module(module="migrations.test_migrations") as migration_dir: |
