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


Python PyObjC_TestClass3.setKeyValue_forObject_key_value_方法代码示例

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


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

示例1: testKVO3

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import setKeyValue_forObject_key_value_ [as 别名]
        def testKVO3(self):
            """
            Check if observations work for python-based keys on ObjC classes
            """
            observer = KeyValueObserver.alloc().init()
            self.assertEqual(observer.observed, [])

            o = KeyValueClass1.alloc().init()
            STUB.setKeyValue_forObject_key_value_(2, o, b'key3'.decode('ascii'), b'three'.decode('ascii'))

            o.addObserver_forKeyPath_options_context_(observer, b"key3".decode('ascii'),
                    NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld,
                    0)
            try:
                STUB.setKeyValue_forObject_key_value_(2, o, b'key3'.decode('ascii'), b'drie'.decode('ascii'))
                self.assertEqual(o.key3, b"drie".decode('ascii'))

                self.assertEqual(len(observer.observed), 1)

                keyPath, object, change = observer.observed[0]
                self.assertEqual(keyPath, b"key3".decode('ascii'))
                self.assert_(object is o)
                self.assertEqual(change,
                    {
                        NSKeyValueChangeKindKey:1,
                        NSKeyValueChangeNewKey:b'drie'.decode('ascii'),
                        NSKeyValueChangeOldKey:b'three'.decode('ascii')
                    })

            finally:
                o.removeObserver_forKeyPath_(observer, b'key3'.decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:33,代码来源:test_keyvalue.py

示例2: testKVO3

# 需要导入模块: from PyObjCTest.testhelper import PyObjC_TestClass3 [as 别名]
# 或者: from PyObjCTest.testhelper.PyObjC_TestClass3 import setKeyValue_forObject_key_value_ [as 别名]
        def testKVO3(self):
            """
            Check if observations work for python-based keys on ObjC classes
            """
            observer = KeyValueObserver.alloc().init()
            self.assertEquals(observer.observed, [])

            o = KeyValueClass1.alloc().init()
            STUB.setKeyValue_forObject_key_value_(2, o, u'key3', u'three')

            o.addObserver_forKeyPath_options_context_(observer, u"key3",
                    NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld,
                    0)
            try:
                STUB.setKeyValue_forObject_key_value_(2, o, u'key3', u'drie')
                self.assertEquals(o.key3, u"drie")

                self.assertEquals(len(observer.observed), 1)

                keyPath, object, change = observer.observed[0]
                self.assertEquals(keyPath, u"key3")
                self.assert_(object is o)
                self.assertEquals(change,
                    {
                        NSKeyValueChangeKindKey:1,
                        NSKeyValueChangeNewKey:u'drie',
                        NSKeyValueChangeOldKey:u'three'
                    })

            finally:
                o.removeObserver_forKeyPath_(observer, u'key3')
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:33,代码来源:test_keyvalue.py

示例3: testTakeValueForKey2

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

        self.assertEquals(o.foo, u"foobar")
        STUB.setKeyValue_forObject_key_value_(0, o, u'foo', u'FOO')
        self.assertEquals(o.foo, u"FOO")

        self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, 0, o, u'key9', u'IX')
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:10,代码来源:test_keyvalue.py

示例4: testTakeValueForKey2

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

        self.assertEqual(o.foo, b"foobar".decode('ascii'))
        STUB.setKeyValue_forObject_key_value_(0, o, b'foo'.decode('ascii'), b'FOO'.decode('ascii'))
        self.assertEqual(o.foo, b"FOO".decode('ascii'))

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

示例5: testTakeValuesFromDictionary2

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

        self.assertEquals(o.foo, u"foobar")
        STUB.setKeyValue_forObject_key_value_(3, o, None, { u'foo': u'FOO' })
        self.assertEquals(o.foo, u"FOO")

        self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, 3, o, None, { u'key9':  u'IX' })
        self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, 3, o, None, { u'roprop':  u'IX' })
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:11,代码来源:test_keyvalue.py

示例6: testTakeValuesFromDictionary2

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

        self.assertEqual(o.foo, b"foobar".decode('ascii'))
        STUB.setKeyValue_forObject_key_value_(3, o, None, { b'foo'.decode('ascii'): b'FOO'.decode('ascii') })
        self.assertEqual(o.foo, b"FOO".decode('ascii'))

        self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, 3, o, None, { b'key9'.decode('ascii'):  b'IX'.decode('ascii') })
        self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, 3, o, None, { b'roprop'.decode('ascii'):  b'IX'.decode('ascii') })
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:11,代码来源:test_keyvalue.py

示例7: testTakeValueForKeyPath

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

        self.assertEquals(o._values['multiple']._values['level2']._values['level3']._values['keyA'], u"hello")
        self.assertEquals(o._values['multiple']._values['level2']._values['level3']._values['keyB'], u"world")

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

        STUB.setKeyValue_forObject_key_value_(1, o, u"multiple.level2.level3.keyB", 9.999)
        self.assertEquals(o._values['multiple']._values['level2']._values['level3']._values['keyB'], 9.999)
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:14,代码来源:test_keyvalue.py

示例8: testTakeValueForKeyPath

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

        self.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyA'], b"hello".decode('ascii'))
        self.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyB'], b"world".decode('ascii'))

        STUB.setKeyValue_forObject_key_value_(1, o, b"multiple.level2.level3.keyA".decode('ascii'), b"KeyAValue".decode('ascii'))
        self.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyA'], b"KeyAValue".decode('ascii'))

        STUB.setKeyValue_forObject_key_value_(1, o, b"multiple.level2.level3.keyB".decode('ascii'), 9.999)
        self.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyB'], 9.999)
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:14,代码来源:test_keyvalue.py

示例9: testTakeValuesFromDictionary

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

        self.assertEquals(o._values['key3'], 3)
        self.assertEquals(o._values['key4'], u"4")
        o._values['key5'] = 1
        self.assert_('key9' not in o._values)

        STUB.setKeyValue_forObject_key_value_(3, o, None,
            {
                u'key3': u'drie',
                u'key4': u'vier',
                u'key5': u'V',
                u'key9': u'IX',
            })

        self.assertEquals(o._values['key3'], u"drie")
        self.assertEquals(o._values['key4'], u"viervierviervier")
        self.assertEquals(o._values['key5'], u"VVVVV")
        self.assertEquals(o._values['key9'], u'IX')
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:22,代码来源:test_keyvalue.py

示例10: testTakeValuesFromDictionary

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

        self.assertEqual(o._values['key3'], 3)
        self.assertEqual(o._values['key4'], b"4".decode('ascii'))
        o._values['key5'] = 1
        self.assert_('key9' not in o._values)

        STUB.setKeyValue_forObject_key_value_(3, o, None,
            {
                b'key3'.decode('ascii'): b'drie'.decode('ascii'),
                b'key4'.decode('ascii'): b'vier'.decode('ascii'),
                b'key5'.decode('ascii'): b'V'.decode('ascii'),
                b'key9'.decode('ascii'): b'IX'.decode('ascii'),
            })

        self.assertEqual(o._values['key3'], b"drie".decode('ascii'))
        self.assertEqual(o._values['key4'], b"viervierviervier".decode('ascii'))
        self.assertEqual(o._values['key5'], b"VVVVV".decode('ascii'))
        self.assertEqual(o._values['key9'], b'IX'.decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:22,代码来源:test_keyvalue.py

示例11: testTakeStoredValueForKey

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

        self.assertEquals(o._values['key3'], 3)
        STUB.setKeyValue_forObject_key_value_(2, o, u'key3', u'drie')
        self.assertEquals(o._values['key3'], u"drie")

        self.assertEquals(o._values['key4'], u"4")
        STUB.setKeyValue_forObject_key_value_(2, o, u'key4', u'vier')
        self.assertEquals(o._values['key4'], u"viervierviervier")

        o.key5 = 1
        STUB.setKeyValue_forObject_key_value_(2, o, u'key5', u'V')
        self.assertEquals(o._values['key5'], u"VVVVV")

        self.assert_('key9' not in o._values)
        STUB.setKeyValue_forObject_key_value_(2, o, u'key9', u'IX')
        self.assert_('key9' in o._values)
        self.assertEquals(o._values['key9'], u'IX')
开发者ID:Joey-Lee,项目名称:pyobjc,代码行数:21,代码来源:test_keyvalue.py

示例12: testTakeStoredValueForKey

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

        self.assertEqual(o.key3, 3)
        STUB.setKeyValue_forObject_key_value_(2, o, b'key3'.decode('ascii'), b'drie'.decode('ascii'))
        self.assertEqual(o.key3, b"drie".decode('ascii'))

        self.assertEqual(o._key4, b"4".decode('ascii'))
        STUB.setKeyValue_forObject_key_value_(2, o, b'key4'.decode('ascii'), b'vier'.decode('ascii'))
        self.assertEqual(o._key4, b"viervierviervier".decode('ascii'))

        o.key5 = 1
        STUB.setKeyValue_forObject_key_value_(2, o, b'key5'.decode('ascii'), b'V'.decode('ascii'))
        self.assertEqual(o.key5, b"VVVVV".decode('ascii'))

        self.assert_(not hasattr(o, b'key9'.decode('ascii')))
        STUB.setKeyValue_forObject_key_value_(2, o, b'key9'.decode('ascii'), b'IX'.decode('ascii'))
        self.assert_(hasattr(o, b'key9'.decode('ascii')))
        self.assertEqual(o.key9, b'IX'.decode('ascii'))
开发者ID:benoit-pierre,项目名称:pyobjc,代码行数:21,代码来源:test_keyvalue.py


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