diff options
| author | Dakota Hawkins <dakotahawkins@users.noreply.github.com> | 2018-12-19 06:41:31 -0500 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2018-12-19 12:41:31 +0100 |
| commit | 8d3147e130c4e5638fceb1e6125c040362ce12e8 (patch) | |
| tree | 3e17b6ed50be3466ced3ec73a2745f37f994cebb /tests | |
| parent | b514dc14f4e1c364341f5931b354e83ef15ee12d (diff) | |
Fixed #30031 -- Added --no-header option to makemigrations/squashmigrations.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_writer.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index f7ec6f4bd3..467ff4475b 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -613,16 +613,21 @@ class WriterTests(SimpleTestCase): }) dt = datetime.datetime(2015, 7, 31, 4, 40, 0, 0, tzinfo=utc) with mock.patch('django.db.migrations.writer.now', lambda: dt): - writer = MigrationWriter(migration) - output = writer.as_string() + for include_header in (True, False): + with self.subTest(include_header=include_header): + writer = MigrationWriter(migration, include_header) + output = writer.as_string() - self.assertTrue( - output.startswith( - "# Generated by Django %(version)s on 2015-07-31 04:40\n" % { - 'version': get_version(), - } - ) - ) + self.assertEqual( + include_header, + output.startswith( + "# Generated by Django %s on 2015-07-31 04:40\n\n" % get_version() + ) + ) + if not include_header: + # Make sure the output starts with something that's not + # a comment or indentation or blank line + self.assertRegex(output.splitlines(keepends=True)[0], r"^[^#\s]+") def test_models_import_omitted(self): """ |
