diff options
| author | Christopher Luc <chris.luc.dev@gmail.com> | 2015-03-28 17:09:44 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-04-10 07:04:26 -0400 |
| commit | a7bc00e17bebe34cdf23f744937b3c386ee73d81 (patch) | |
| tree | d7112ede95acbdd5052df1dbfbbb4a88be0581b1 /tests | |
| parent | d5d92260bbc5b00abc9d59a1987efb6a322bd3cd (diff) | |
Fixed #24514 -- Made migration writer omit models import if it's unused.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_writer.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index 46531df791..f0edfd3e30 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -512,6 +512,22 @@ class WriterTests(TestCase): output ) + def test_models_import_omitted(self): + """ + django.db.models shouldn't be imported if unused. + """ + migration = type(str("Migration"), (migrations.Migration,), { + "operations": [ + migrations.AlterModelOptions( + name='model', + options={'verbose_name': 'model', 'verbose_name_plural': 'models'}, + ), + ] + }) + writer = MigrationWriter(migration) + output = writer.as_string().decode('utf-8') + self.assertIn("from django.db import migrations\n", output) + def test_deconstruct_class_arguments(self): # Yes, it doesn't make sense to use a class as a default for a # CharField. It does make sense for custom fields though, for example |
