本文整理汇总了Python中pyamf.tests.util.Spam类的典型用法代码示例。如果您正苦于以下问题:Python Spam类的具体用法?Python Spam怎么用?Python Spam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spam类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
示例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")
示例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")
示例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')])
示例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')
示例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')])
示例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')
示例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')
示例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')
示例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'))])
示例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")
示例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')
示例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')
示例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")
示例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)