當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。