本文整理汇总了Python中django.db.models.query.CollectedObjects.ordered_keys方法的典型用法代码示例。如果您正苦于以下问题:Python CollectedObjects.ordered_keys方法的具体用法?Python CollectedObjects.ordered_keys怎么用?Python CollectedObjects.ordered_keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.query.CollectedObjects
的用法示例。
在下文中一共展示了CollectedObjects.ordered_keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nullable_related_fields_collected_objects
# 需要导入模块: from django.db.models.query import CollectedObjects [as 别名]
# 或者: from django.db.models.query.CollectedObjects import ordered_keys [as 别名]
def test_nullable_related_fields_collected_objects(self):
## First, test the CollectedObjects data structure directly
g = CollectedObjects()
self.assertFalse(g.add("key1", 1, "item1", None))
self.assertFalse(g.add("key2", 1, "item1", "key1", nullable=True))
self.assertTrue(g.add("key1", 1, "item1", "key2"))
self.assertEqual(g.ordered_keys(), ['key1', 'key2'])
示例2: test_collected_objects_data_structure
# 需要导入模块: from django.db.models.query import CollectedObjects [as 别名]
# 或者: from django.db.models.query.CollectedObjects import ordered_keys [as 别名]
def test_collected_objects_data_structure(self):
## Test the CollectedObjects data structure directly
g = CollectedObjects()
self.assertFalse(g.add("key1", 1, "item1", None))
self.assertEqual(g["key1"], {1: 'item1'})
self.assertFalse(g.add("key2", 1, "item1", "key1"))
self.assertFalse(g.add("key2", 2, "item2", "key1"))
self.assertEqual(g["key2"], {1: 'item1', 2: 'item2'})
self.assertFalse(g.add("key3", 1, "item1", "key1"))
self.assertTrue(g.add("key3", 1, "item1", "key2"))
self.assertEqual(g.ordered_keys(), ['key3', 'key2', 'key1'])
self.assertTrue(g.add("key2", 1, "item1", "key3"))
self.assertRaises(CyclicDependency,
g.ordered_keys)
示例3: test_collected_objects
# 需要导入模块: from django.db.models.query import CollectedObjects [as 别名]
# 或者: from django.db.models.query.CollectedObjects import ordered_keys [as 别名]
def test_collected_objects(self):
g = CollectedObjects()
self.assertFalse(g.add("key1", 1, "item1", None))
self.assertEqual(g["key1"], {1: "item1"})
self.assertFalse(g.add("key2", 1, "item1", "key1"))
self.assertFalse(g.add("key2", 2, "item2", "key1"))
self.assertEqual(g["key2"], {1: "item1", 2: "item2"})
self.assertFalse(g.add("key3", 1, "item1", "key1"))
self.assertTrue(g.add("key3", 1, "item1", "key2"))
self.assertEqual(g.ordered_keys(), ["key3", "key2", "key1"])
self.assertTrue(g.add("key2", 1, "item1", "key3"))
self.assertRaises(CyclicDependency, g.ordered_keys)
示例4: test_collected_objects_null
# 需要导入模块: from django.db.models.query import CollectedObjects [as 别名]
# 或者: from django.db.models.query.CollectedObjects import ordered_keys [as 别名]
def test_collected_objects_null(self):
g = CollectedObjects()
self.assertFalse(g.add("key1", 1, "item1", None))
self.assertFalse(g.add("key2", 1, "item1", "key1", nullable=True))
self.assertTrue(g.add("key1", 1, "item1", "key2"))
self.assertEqual(g.ordered_keys(), ["key1", "key2"])