本文整理汇总了Python中pyamf.tests.util.Spam.context方法的典型用法代码示例。如果您正苦于以下问题:Python Spam.context方法的具体用法?Python Spam.context怎么用?Python Spam.context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyamf.tests.util.Spam
的用法示例。
在下文中一共展示了Spam.context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loadInstanceFromDatastore
# 需要导入模块: from pyamf.tests.util import Spam [as 别名]
# 或者: from pyamf.tests.util.Spam import context [as 别名]
def test_loadInstanceFromDatastore(self):
# not a class type
self.assertRaises(TypeError, adapter_db.loadInstanceFromDatastore, chr, "")
# not a subclass of db.Model/db.Expando
self.assertRaises(TypeError, adapter_db.loadInstanceFromDatastore, Spam, "")
# not a valid key type
self.assertRaises(TypeError, adapter_db.loadInstanceFromDatastore, GettableModelStub, 2)
self.assertEquals(GettableModelStub.gets, [])
adapter_db.loadInstanceFromDatastore(GettableModelStub, "foo", codec=None)
self.assertEquals(GettableModelStub.gets, [[("foo",), {}]])
codec = Spam()
codec.context = Spam()
GettableModelStub.gets = []
self.assertFalse(hasattr(codec.context, "gae_objects"))
adapter_db.loadInstanceFromDatastore(GettableModelStub, "foo", codec=codec)
self.assertTrue(hasattr(codec.context, "gae_objects"))
self.assertEquals(GettableModelStub.gets, [[("foo",), {}]])
gae_objects = codec.context.gae_objects
self.assertTrue(isinstance(gae_objects, adapter_db.GAEReferenceCollection))
self.assertEquals(gae_objects, {GettableModelStub: {"foo": None}})