本文整理汇总了Python中twisted.protocols.amp.Argument方法的典型用法代码示例。如果您正苦于以下问题:Python amp.Argument方法的具体用法?Python amp.Argument怎么用?Python amp.Argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.protocols.amp
的用法示例。
在下文中一共展示了amp.Argument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_argumentInterface
# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Argument [as 别名]
def test_argumentInterface(self):
"""
L{Argument} instances provide L{amp.IArgumentType}.
"""
self.assertTrue(verifyObject(amp.IArgumentType, amp.Argument()))
示例2: test_commandArgumentsMustBeNamedWithByteStrings
# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Argument [as 别名]
def test_commandArgumentsMustBeNamedWithByteStrings(self):
"""
A L{Command} subclass's C{arguments} must have byte string names.
"""
error = self.assertRaises(
TypeError, type, "NewCommand", (amp.Command, ),
{"arguments": [(u"foo", None)]})
self.assertRegex(
str(error), "^Argument names must be byte strings, got: u?'foo'$")
示例3: test_toBox
# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Argument [as 别名]
def test_toBox(self):
"""
L{ListOf.toBox} extracts the list of objects from the C{objects}
dictionary passed to it, using the C{name} key also passed to it,
serializes each of the elements in that list using the L{Argument}
instance previously passed to its initializer, combines the serialized
results, and inserts the result into the C{strings} dictionary using
the same C{name} key.
"""
stringList = amp.ListOf(self.elementType)
strings = amp.AmpBox()
for key in self.objects:
stringList.toBox(
key.encode("ascii"), strings, self.objects.copy(), None)
self.assertEqual(strings, self.strings)
示例4: test_toBox
# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Argument [as 别名]
def test_toBox(self):
"""
L{ListOf.toBox} extracts the list of objects from the C{objects}
dictionary passed to it, using the C{name} key also passed to it,
serializes each of the elements in that list using the L{Argument}
instance previously passed to its initializer, combines the serialized
results, and inserts the result into the C{strings} dictionary using
the same C{name} key.
"""
stringList = amp.ListOf(self.elementType)
strings = amp.AmpBox()
for key in self.objects:
stringList.toBox(key, strings, self.objects.copy(), None)
self.assertEquals(strings, self.strings)
示例5: fromString
# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Argument [as 别名]
def fromString(self, inString):
# inString is always a byte string, as defined by amp.Argument.
return inString