MCPcopy
hub / github.com/django/django / test_sorted_imports

Method test_sorted_imports

tests/migrations/test_writer.py:1128–1159  ·  view source on GitHub ↗

#24155 - Tests ordering of imports.

(self)

Source from the content-addressed store, hash-verified

1126 )
1127
1128 def test_sorted_imports(self):
1129 """
1130 #24155 - Tests ordering of imports.
1131 """
1132 migration = type(
1133 "Migration",
1134 (migrations.Migration,),
1135 {
1136 "operations": [
1137 migrations.AddField(
1138 "mymodel",
1139 "myfield",
1140 models.DateTimeField(
1141 default=datetime.datetime(
1142 2012, 1, 1, 1, 1, tzinfo=datetime.UTC
1143 ),
1144 ),
1145 ),
1146 migrations.AddField(
1147 "mymodel",
1148 "myfield2",
1149 models.FloatField(default=time.time),
1150 ),
1151 ]
1152 },
1153 )
1154 writer = MigrationWriter(migration)
1155 output = writer.as_string()
1156 self.assertIn(
1157 "import datetime\nimport time\nfrom django.db import migrations, models\n",
1158 output,
1159 )
1160
1161 def test_migration_file_header_comments(self):
1162 """

Callers

nothing calls this directly

Calls 2

as_stringMethod · 0.95
MigrationWriterClass · 0.90

Tested by

no test coverage detected