本文整理汇总了Python中pyamf.tests.util.Spam类的典型用法代码示例。如果您正苦于以下问题:Python Spam类的具体用法?Python Spam怎么用?Python Spam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spam类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_typed_object
def test_typed_object(self):
pyamf.register_class(Spam, alias="org.pyamf.spam")
x = Spam()
x.baz = "hello"
self.assertEncoded(x, "\x10\x00\x0eorg.pyamf.spam\x00\x03baz" "\x02\x00\x05hello\x00\x00\t")
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:7,代码来源:test_amf0.py
示例2: test_force_amf3
def test_force_amf3(self):
alias = pyamf.register_class(Spam, "spam.eggs")
alias.amf3 = True
x = Spam()
x.x = "y"
self.assertEncoded(x, "\x11\n\x0b\x13spam.eggs\x03x\x06\x03y\x01")
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:8,代码来源:test_amf0.py
示例3: test_anonymous
def test_anonymous(self):
pyamf.register_class(Spam)
x = Spam()
x.spam = "eggs"
x.hello = "world"
self.assertEncoded(x, "\x03", ("\x00\x05hello\x02\x00\x05world", "\x00\x04spam\x02\x00\x04eggs"), "\x00\x00\t")
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:8,代码来源:test_amf0.py
示例4: test_force_amf3
def test_force_amf3(self):
pyamf.register_class(Spam, 'spam.eggs', metadata=['amf3'])
x = Spam()
x.x = 'y'
self._run([
(x, '\x11\n\x0b\x13spam.eggs\x03x\x06\x03y\x01')])
开发者ID:AbsMate,项目名称:bluecop-xbmc-repo,代码行数:8,代码来源:test_amf0.py
示例5: test_typed_object
def test_typed_object(self):
pyamf.register_class(Spam, alias='org.pyamf.spam')
x = Spam()
x.baz = 'hello'
self.assertEncoded(x, '\x10\x00\x0eorg.pyamf.spam\x00\x03baz'
'\x02\x00\x05hello\x00\x00\t')
开发者ID:notnola,项目名称:pinychat,代码行数:8,代码来源:test_amf0.py
示例6: test_anonymous
def test_anonymous(self):
pyamf.register_class(Spam)
x = Spam()
x.spam = 'eggs'
x.hello = 'world'
self._run([
(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x04spam\x02\x00\x04eggs\x00\x00\t')])
开发者ID:wayne-abarquez,项目名称:vizzuality,代码行数:9,代码来源:test_amf0.py
示例7: test_anonymous
def test_anonymous(self):
pyamf.register_class(Spam)
x = Spam()
x.spam = 'eggs'
x.hello = 'world'
self.assertEncoded(x, '\x03', ('\x00\x05hello\x02\x00\x05world',
'\x00\x04spam\x02\x00\x04eggs'), '\x00\x00\t')
开发者ID:notnola,项目名称:pinychat,代码行数:9,代码来源:test_amf0.py
示例8: test_typed_object
def test_typed_object(self):
pyamf.register_class(Spam, alias='org.pyamf.spam')
x = Spam()
x.baz = 'hello'
self.encoder.writeElement(x)
self.assertEquals(self.buf.getvalue(),
'\x10\x00\x0eorg.pyamf.spam\x00\x03baz\x02\x00\x05hello\x00\x00\t')
开发者ID:cardmagic,项目名称:PyAMF,代码行数:10,代码来源:test_amf0.py
示例9: test_object
def test_object(self):
self.assertEncoded({'a': u'spam', 'b': 5},
'\n\x0b\x01\x03a\x06\tspam\x03b\x04\x05\x01')
pyamf.register_class(Spam, 'org.pyamf.spam')
obj = Spam()
obj.baz = 'hello'
self.assertEncoded(obj,
'\n\x0b\x1dorg.pyamf.spam\x07baz\x06\x0bhello\x01')
开发者ID:MyaThandarKyaw,项目名称:pyamf,代码行数:11,代码来源:test_amf3.py
示例10: test_dynamic
def test_dynamic(self):
def attr_func(obj):
self.assertTrue(isinstance(obj, Spam))
return ['hello']
x = Spam()
x.foo = 'bar'
x.hello = 'world'
pyamf.register_class(Spam, attr_func=attr_func, metadata=['dynamic'])
self._run([(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Spam)
# try duplicate attributes
pyamf.register_class(Spam, attrs=['hello'], attr_func=attr_func,
metadata=['dynamic'])
self._run([(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Spam)
pyamf.register_class(Spam, attrs=['foo'], attr_func=attr_func,
metadata=['dynamic'])
self._run([
(x, ('\x03', (
'\x00\x03foo\x02\x00\x03bar',
'\x00\x05hello\x02\x00\x05world'
), '\x00\x00\t'))])
pyamf.unregister_class(Spam)
# and now typedobject
pyamf.register_class(Spam, 'x', attr_func=attr_func,
metadata=['dynamic'])
self._run([(x,
'\x10\x00\x01x\x00\x05hello\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Spam)
pyamf.register_class(Spam, 'x', attrs=['hello'], attr_func=attr_func,
metadata=['dynamic'])
self._run([(x,
'\x10\x00\x01x\x00\x05hello\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Spam)
pyamf.register_class(Spam, 'x', attrs=['foo'], attr_func=attr_func,
metadata=['dynamic'])
self._run([
(x, ('\x10\x00\x01x', (
'\x00\x03foo\x02\x00\x03bar',
'\x00\x05hello\x02\x00\x05world'
), '\x00\x00\t'))])
开发者ID:AbsMate,项目名称:bluecop-xbmc-repo,代码行数:51,代码来源:test_amf0.py
示例11: test_dynamic_static
def test_dynamic_static(self):
x = Spam()
x.foo = "bar"
x.hello = "world"
alias = pyamf.register_class(Spam)
alias.static_attrs = ["hello"]
alias.compile()
self.assertTrue(alias.dynamic)
self.assertEncoded(x, "\x03", ("\x00\x05hello\x02\x00\x05world", "\x00\x03foo\x02\x00\x03bar"), "\x00\x00\t")
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:14,代码来源:test_amf0.py
示例12: test_dynamic
def test_dynamic(self):
x = Spam()
x.foo = 'bar'
x.hello = 'world'
alias = pyamf.register_class(Spam)
alias.exclude_attrs = ['foo']
alias.compile()
self.assertTrue(alias.dynamic)
self.assertEncoded(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x00\t')
开发者ID:LiiiQin,项目名称:test,代码行数:15,代码来源:test_amf0.py
示例13: test_dynamic_static
def test_dynamic_static(self):
x = Spam()
x.foo = 'bar'
x.hello = 'world'
alias = pyamf.register_class(Spam)
alias.static_attrs = ['hello']
alias.compile()
self.assertTrue(alias.dynamic)
self.assertEncoded(x, '\x03', ('\x00\x05hello\x02\x00\x05world',
'\x00\x03foo\x02\x00\x03bar'), '\x00\x00\t')
开发者ID:notnola,项目名称:pinychat,代码行数:15,代码来源:test_amf0.py
示例14: test_dynamic_registered
def test_dynamic_registered(self):
x = Spam()
x.foo = "bar"
x.hello = "world"
alias = pyamf.register_class(Spam, "x")
alias.exclude_attrs = ["foo"]
alias.compile()
self.assertTrue(alias.dynamic)
self.assertEncoded(x, "\x10\x00\x01x", "\x00\x05hello\x02\x00\x05world", "\x00\x00\t")
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:15,代码来源:test_amf0.py
示例15: test_object
def test_object(self):
self._run([
({'a': u'spam', 'b': 5},
'\n\x0b\x01\x03a\x06\tspam\x03b\x04\x05\x01')])
pyamf.register_class(Spam, 'org.pyamf.spam')
obj = Spam()
obj.baz = 'hello'
self.encoder.writeElement(obj)
self.assertEqual(self.buf.getvalue(), '\n\x0b\x1dorg.pyamf.spam\x07baz'
'\x06\x0bhello\x01')
pyamf.unregister_class(Spam)
开发者ID:wayne-abarquez,项目名称:vizzuality,代码行数:16,代码来源:test_amf3.py
示例16: test_dynamic
def test_dynamic(self):
x = Spam()
x.foo = 'bar'
x.hello = 'world'
alias = pyamf.register_class(Spam)
alias.exclude_attrs = ['foo']
alias.compile()
self.assertTrue(alias.dynamic)
self._run([(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x00\t')])
pyamf.unregister_class(Spam)
# try duplicate attributes
alias = pyamf.register_class(Spam)
alias.static_attrs = ['hello']
alias.compile()
self.assertTrue(alias.dynamic)
self._run([(x, '\x03\x00\x05hello\x02\x00\x05world\x00\x03foo\x02'
'\x00\x03bar\x00\x00\t')])
pyamf.unregister_class(Spam)
# and now typedobject
alias = pyamf.register_class(Spam, 'x')
alias.exclude_attrs = ['foo']
alias.compile()
self.assertTrue(alias.dynamic)
self._run([(x,
'\x10\x00\x01x\x00\x05hello\x02\x00\x05world\x00\x00\t')])
开发者ID:cardmagic,项目名称:PyAMF,代码行数:40,代码来源:test_amf0.py
示例17: test_loadInstanceFromDatastore
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}})
开发者ID:jrolfs,项目名称:google-calendar-amf,代码行数:24,代码来源:test_google.py
注:本文中的pyamf.tests.util.Spam类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论