MCPcopy
hub / github.com/django/django / test_models_import_omitted

Method test_models_import_omitted

tests/migrations/test_writer.py:1187–1208  ·  view source on GitHub ↗

django.db.models shouldn't be imported if unused.

(self)

Source from the content-addressed store, hash-verified

1185 )
1186
1187 def test_models_import_omitted(self):
1188 """
1189 django.db.models shouldn't be imported if unused.
1190 """
1191 migration = type(
1192 "Migration",
1193 (migrations.Migration,),
1194 {
1195 "operations": [
1196 migrations.AlterModelOptions(
1197 name="model",
1198 options={
1199 "verbose_name": "model",
1200 "verbose_name_plural": "models",
1201 },
1202 ),
1203 ]
1204 },
1205 )
1206 writer = MigrationWriter(migration)
1207 output = writer.as_string()
1208 self.assertIn("from django.db import migrations\n", output)
1209
1210 def test_deconstruct_class_arguments(self):
1211 # Yes, it doesn't make sense to use a class as a default for a

Callers

nothing calls this directly

Calls 2

as_stringMethod · 0.95
MigrationWriterClass · 0.90

Tested by

no test coverage detected