本文整理匯總了Python中twisted.protocols.amp.Boolean方法的典型用法代碼示例。如果您正苦於以下問題:Python amp.Boolean方法的具體用法?Python amp.Boolean怎麽用?Python amp.Boolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.protocols.amp
的用法示例。
在下文中一共展示了amp.Boolean方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_booleanValues
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import Boolean [as 別名]
def test_booleanValues(self):
"""
Verify that the Boolean parser parses 'True' and 'False', but nothing
else.
"""
b = amp.Boolean()
self.assertTrue(b.fromString(b"True"))
self.assertFalse(b.fromString(b"False"))
self.assertRaises(TypeError, b.fromString, b"ninja")
self.assertRaises(TypeError, b.fromString, b"true")
self.assertRaises(TypeError, b.fromString, b"TRUE")
self.assertEqual(b.toString(True), b'True')
self.assertEqual(b.toString(False), b'False')
示例2: test_booleanValues
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import Boolean [as 別名]
def test_booleanValues(self):
"""
Verify that the Boolean parser parses 'True' and 'False', but nothing
else.
"""
b = amp.Boolean()
self.assertEquals(b.fromString("True"), True)
self.assertEquals(b.fromString("False"), False)
self.assertRaises(TypeError, b.fromString, "ninja")
self.assertRaises(TypeError, b.fromString, "true")
self.assertRaises(TypeError, b.fromString, "TRUE")
self.assertEquals(b.toString(True), 'True')
self.assertEquals(b.toString(False), 'False')