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


Python PyObjC_TestClass3.keyValue_forObject_key_方法代码示例

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


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

示例1: testStoredValueForKey

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testStoredValueForKey(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"key1".decode('ascii')), 1)
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"key2".decode('ascii')), 2)
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"key3".decode('ascii')), 3)
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"key4".decode('ascii')), "4")
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"multiple".decode('ascii')), o.multiple)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 2, o, b"nokey".decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:13,代码来源:test_keyvalue.py

示例2: testStoredValueForKey

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testStoredValueForKey(self):
        o = KeyValueClass1Explicit.alloc().init()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"key1"), 1)
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"key2"), 2)
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"key3"), 3)
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"key4"), "4")
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"multiple"), o._values['multiple'])

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 2, o, u"nokey")
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:13,代码来源:test_keyvalue.py

示例3: testValueForKeyPath

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testValueForKeyPath(self):
        o = KeyValueClass1Explicit.alloc().init()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(1, o, u"multiple"), o._values['multiple'])
        self.assertEquals(STUB.keyValue_forObject_key_(1, o, u"multiple.level2"), o._values['multiple']._values['level2'])
        self.assertEquals(STUB.keyValue_forObject_key_(1, o, u"multiple.level2.level3.keyA"),
            o._values['multiple']._values['level2']._values['level3']._values['keyA'])
        self.assertEquals(STUB.keyValue_forObject_key_(1, o, u"multiple.level2.level3.keyB"),
            o._values['multiple']._values['level2']._values['level3']._values['keyB'])

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 1, o, u"multiple.level2.nokey")
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:14,代码来源:test_keyvalue.py

示例4: testValueForKey

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testValueForKey(self):
        o = KeyValueClass1Explicit.alloc().init()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(0, o, b"key1".decode('ascii')), 1)

        self.assertEqual(STUB.keyValue_forObject_key_(0, o, b"key2".decode('ascii')), 2)
        self.assertEqual(STUB.keyValue_forObject_key_(0, o, b"key3".decode('ascii')), 3)
        self.assertEqual(STUB.keyValue_forObject_key_(0, o, b"key4".decode('ascii')), "4")
        self.assertEqual(STUB.keyValue_forObject_key_(0, o, b"multiple".decode('ascii')), o._values['multiple'])

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o, b"nokey".decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:14,代码来源:test_keyvalue.py

示例5: testValueForKey

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testValueForKey(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(0, o, u"key1"), 1)

        self.assertEquals(STUB.keyValue_forObject_key_(0, o, u"key2"), 2)
        self.assertEquals(STUB.keyValue_forObject_key_(0, o, u"key3"), 3)
        self.assertEquals(STUB.keyValue_forObject_key_(0, o, u"key4"), "4")
        self.assertEquals(STUB.keyValue_forObject_key_(0, o, u"multiple"), o.multiple)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o, u"nokey")

        self.assertRaises(ValueError, STUB.keyValue_forObject_key_, 0, o,
                u"keyRaisingValueError")
        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o,
                u"keyRaisingNSUnknownKeyException")
        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o,
                u"keyReturningSameSelector")

        obj = STUB.keyValue_forObject_key_( 0, o, u"keyReturningOtherSelector")
        self.failUnless( isinstance(obj, objc.selector) )
        self.assertEquals(obj.selector, "getKey1")
        self.failUnless( obj.self is o )
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:26,代码来源:test_keyvalue.py

示例6: testValuesForKeys

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testValuesForKeys(self):
        o = KeyValueClass1Explicit.alloc().init()

        self.assertEquals(STUB.keyValue_forObject_key_(3, o, [u"key1", u"key2", u"key3", u"key4"]), { u"key1":1, u"key2":2, u"key3": 3, u"key4": u"4"} )

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 3, o, [u"key1", u"key3", u"nosuchkey"])
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:8,代码来源:test_keyvalue.py

示例7: testStoredValueForKey2

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testStoredValueForKey2(self):
        o = KeyValueClass4.alloc().init()

        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"foo"), u"foobar")
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"bar"), u"foobarfoobar")
        self.assertEquals(STUB.keyValue_forObject_key_(2, o, u"roprop"), u"read-only")
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:8,代码来源:test_keyvalue.py

示例8: testValuesForKeys

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testValuesForKeys(self):
        o = KeyValueClass1Explicit.alloc().init()

        self.assertEqual(STUB.keyValue_forObject_key_(3, o, [b"key1".decode('ascii'), b"key2".decode('ascii'), b"key3".decode('ascii'), b"key4".decode('ascii')]), { b"key1".decode('ascii'):1, b"key2".decode('ascii'):2, b"key3".decode('ascii'): 3, b"key4".decode('ascii'): b"4".decode('ascii')} )

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 3, o, [b"key1".decode('ascii'), b"key3".decode('ascii'), b"nosuchkey".decode('ascii')])
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:8,代码来源:test_keyvalue.py

示例9: testStoredValueForKey2

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import keyValue_forObject_key_ [as 别名]
    def testStoredValueForKey2(self):
        o = KeyValueClass4.alloc().init()

        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"foo".decode('ascii')), b"foobar".decode('ascii'))
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"bar".decode('ascii')), b"foobarfoobar".decode('ascii'))
        self.assertEqual(STUB.keyValue_forObject_key_(2, o, b"roprop".decode('ascii')), b"read-only".decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:8,代码来源:test_keyvalue.py


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