本文整理匯總了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