|
@@ -768,12 +768,17 @@ class WriterTests(SimpleTestCase):
|
|
|
def test_serialize_frozensets(self):
|
|
|
self.assertSerializedEqual(frozenset())
|
|
|
self.assertSerializedEqual(frozenset("let it go"))
|
|
|
+ self.assertSerializedResultEqual(
|
|
|
+ frozenset("cba"), ("frozenset(['a', 'b', 'c'])", set())
|
|
|
+ )
|
|
|
|
|
|
def test_serialize_set(self):
|
|
|
self.assertSerializedEqual(set())
|
|
|
self.assertSerializedResultEqual(set(), ("set()", set()))
|
|
|
self.assertSerializedEqual({"a"})
|
|
|
self.assertSerializedResultEqual({"a"}, ("{'a'}", set()))
|
|
|
+ self.assertSerializedEqual({"c", "b", "a"})
|
|
|
+ self.assertSerializedResultEqual({"c", "b", "a"}, ("{'a', 'b', 'c'}", set()))
|
|
|
|
|
|
def test_serialize_timedelta(self):
|
|
|
self.assertSerializedEqual(datetime.timedelta())
|
|
@@ -891,6 +896,33 @@ class WriterTests(SimpleTestCase):
|
|
|
result["custom_migration_operations"].more_operations.TestOperation,
|
|
|
)
|
|
|
|
|
|
+ def test_sorted_dependencies(self):
|
|
|
+ migration = type(
|
|
|
+ "Migration",
|
|
|
+ (migrations.Migration,),
|
|
|
+ {
|
|
|
+ "operations": [
|
|
|
+ migrations.AddField("mymodel", "myfield", models.IntegerField()),
|
|
|
+ ],
|
|
|
+ "dependencies": [
|
|
|
+ ("testapp10", "0005_fifth"),
|
|
|
+ ("testapp02", "0005_third"),
|
|
|
+ ("testapp02", "0004_sixth"),
|
|
|
+ ("testapp01", "0001_initial"),
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ )
|
|
|
+ output = MigrationWriter(migration, include_header=False).as_string()
|
|
|
+ self.assertIn(
|
|
|
+ " dependencies = [\n"
|
|
|
+ " ('testapp01', '0001_initial'),\n"
|
|
|
+ " ('testapp02', '0004_sixth'),\n"
|
|
|
+ " ('testapp02', '0005_third'),\n"
|
|
|
+ " ('testapp10', '0005_fifth'),\n"
|
|
|
+ " ]",
|
|
|
+ output,
|
|
|
+ )
|
|
|
+
|
|
|
def test_sorted_imports(self):
|
|
|
"""
|
|
|
#24155 - Tests ordering of imports.
|