当前位置: 首页>>代码示例>>Python>>正文


Python amp.Integer方法代码示例

本文整理汇总了Python中twisted.protocols.amp.Integer方法的典型用法代码示例。如果您正苦于以下问题:Python amp.Integer方法的具体用法?Python amp.Integer怎么用?Python amp.Integer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.protocols.amp的用法示例。


在下文中一共展示了amp.Integer方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sendTableWithName

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_sendTableWithName(self):
        """
        You can send a reference to a table through a L{SchemaAMP} via
        L{TableSyntaxByName}.
        """
        client = AMP()

        class SampleCommand(Command):
            arguments = [("id", Integer())]

        class Receiver(AMP):

            @SampleCommand.responder
            def gotIt(self, id):
                self.it = id
                return {}

        server = Receiver()
        clientT = StringTransport()
        serverT = StringTransport()
        client.makeConnection(clientT)
        server.makeConnection(serverT)
        client.callRemote(SampleCommand, id=123)
        server.dataReceived(clientT.io.getvalue())
        self.assertEqual(server.it, 123) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:27,代码来源:test_jobs.py

示例2: test_requiredArgumentWithNoneValueRaisesTypeError

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_requiredArgumentWithNoneValueRaisesTypeError(self):
        """
        L{ListOf.toBox} raises C{TypeError} when passed a value of L{None}
        for the argument.
        """
        stringList = amp.ListOf(amp.Integer())
        self.assertRaises(
            TypeError, stringList.toBox, b'omitted', amp.AmpBox(),
            {'omitted': None}, None) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_amp.py

示例3: test_optionalArgumentWithNoneValueOmitted

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_optionalArgumentWithNoneValueOmitted(self):
        """
        L{ListOf.toBox} silently omits serializing any argument with a
        value of L{None} that is designated as optional for the protocol.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        strings = amp.AmpBox()
        stringList.toBox(b'omitted', strings, {b'omitted': None}, None)
        self.assertEqual(strings, {}) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_amp.py

示例4: test_requiredArgumentWithKeyMissingRaisesKeyError

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_requiredArgumentWithKeyMissingRaisesKeyError(self):
        """
        L{ListOf.toBox} raises C{KeyError} if the argument's key is not
        present in the objects dictionary.
        """
        stringList = amp.ListOf(amp.Integer())
        self.assertRaises(
            KeyError, stringList.toBox, b'ommited', amp.AmpBox(),
            {'someOtherKey': 0}, None) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_amp.py

示例5: test_optionalArgumentWithKeyMissingOmitted

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_optionalArgumentWithKeyMissingOmitted(self):
        """
        L{ListOf.toBox} silently omits serializing any argument designated
        as optional whose key is not present in the objects dictionary.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        stringList.toBox(b'ommited', amp.AmpBox(), {b'someOtherKey': 0}, None) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:test_amp.py

示例6: test_omittedOptionalArgumentDeserializesAsNone

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_omittedOptionalArgumentDeserializesAsNone(self):
        """
        L{ListOf.fromBox} correctly reverses the operation performed by
        L{ListOf.toBox} for optional arguments.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        objects = {}
        stringList.fromBox(b'omitted', {}, objects, None)
        self.assertEqual(objects, {'omitted': None}) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_amp.py

示例7: txnarg

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def txnarg():
    return [("transactionID", Integer())] 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:4,代码来源:adbapi2.py

示例8: test_requiredArgumentWithNoneValueRaisesTypeError

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_requiredArgumentWithNoneValueRaisesTypeError(self):
        """
        L{ListOf.toBox} raises C{TypeError} when passed a value of C{None}
        for the argument.
        """
        stringList = amp.ListOf(amp.Integer())
        self.assertRaises(
            TypeError, stringList.toBox, 'omitted', amp.AmpBox(),
            {'omitted': None}, None) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_amp.py

示例9: test_optionalArgumentWithNoneValueOmitted

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_optionalArgumentWithNoneValueOmitted(self):
        """
        L{ListOf.toBox} silently omits serializing any argument with a
        value of C{None} that is designated as optional for the protocol.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        strings = amp.AmpBox()
        stringList.toBox('omitted', strings, {'omitted': None}, None)
        self.assertEquals(strings, {}) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_amp.py

示例10: test_requiredArgumentWithKeyMissingRaisesKeyError

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_requiredArgumentWithKeyMissingRaisesKeyError(self):
        """
        L{ListOf.toBox} raises C{KeyError} if the argument's key is not
        present in the objects dictionary.
        """
        stringList = amp.ListOf(amp.Integer())
        self.assertRaises(
            KeyError, stringList.toBox, 'ommited', amp.AmpBox(),
            {'someOtherKey': 0}, None) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_amp.py

示例11: test_optionalArgumentWithKeyMissingOmitted

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_optionalArgumentWithKeyMissingOmitted(self):
        """
        L{ListOf.toBox} silently omits serializing any argument designated
        as optional whose key is not present in the objects dictionary.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        stringList.toBox('ommited', amp.AmpBox(), {'someOtherKey': 0}, None) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:test_amp.py

示例12: test_omittedOptionalArgumentDeserializesAsNone

# 需要导入模块: from twisted.protocols import amp [as 别名]
# 或者: from twisted.protocols.amp import Integer [as 别名]
def test_omittedOptionalArgumentDeserializesAsNone(self):
        """
        L{ListOf.fromBox} correctly reverses the operation performed by
        L{ListOf.toBox} for optional arguments.
        """
        stringList = amp.ListOf(amp.Integer(), optional=True)
        objects = {}
        stringList.fromBox('omitted', {}, objects, None)
        self.assertEquals(objects, {'omitted': None}) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_amp.py


注:本文中的twisted.protocols.amp.Integer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。