How to use the pyobjc.pyobjc.pyobjc-core.PyObjCTest.test_keyvalue.KeyValueClass2 function in pyobjc

To help you get started, we’ve selected a few pyobjc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testTakeValueForKeyPath(self):
        o = KeyValueClass2()
        o.addMultiple()

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

        STUB.setKeyValue_forObject_key_value_(DO_TAKEVALUE_FORKEYPATH, o, u"multiple.level2.level3.keyA", u"KeyAValue")
        self.assertEquals(o.multiple.level2.level3.keyA, u"KeyAValue")

        STUB.setKeyValue_forObject_key_value_(DO_TAKEVALUE_FORKEYPATH, o, u"multiple.level2.level3.keyB", 9.999)
        self.assertEquals(o.multiple.level2.level3.keyB, 9.999)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testStoredValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

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

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_STOREDVALUEFORKEY, o, u"nokey")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def addMultiple(self):
        self.multiple = KeyValueClass2()
        self.multiple.level2 = KeyValueClass2()
        self.multiple.level2.level3 = KeyValueClass2()
        self.multiple.level2.level3.keyA = u"hello"
        self.multiple.level2.level3.keyB = u"world"
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def addMultiple(self):
        self.multiple = KeyValueClass2()
        self.multiple.level2 = KeyValueClass2()
        self.multiple.level2.level3 = KeyValueClass2()
        self.multiple.level2.level3.keyA = u"hello"
        self.multiple.level2.level3.keyB = u"world"
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testPythonConvention(self):
            o = KeyValueClass2()

            self.assertEquals(o._pythonConvention, u'BAD')
            self.assertEquals(o.pythonConvention(), u'GOOD')
            self.assertEquals(o._pythonConventionValue, u'GOOD')
            self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'GOOD')
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'pythonConvention', u'CHANGED')
            self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'CHANGED')
            self.assertEquals(o._pythonConvention, u'BAD')
            self.assertEquals(o.pythonConvention(), u'CHANGED')
            self.assertEquals(o._pythonConventionValue, u'CHANGED')
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testNoPrivateVars(self):
        # Private instance variables ('anObject.__value') are not accessible using
        # key-value coding.
        o = KeyValueClass2()
        self.assertRaises(KeyError,
                STUB.keyValue_forObject_key_, DO_VALUEFORKEY, o, u"private")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testSetValuesForKeysFromDictionary(self):
            o = KeyValueClass2()

            self.assertEquals(o.key3, 3)
            self.assertEquals(o._key4, u"4")
            o.key5 = 1
            self.assertNotHasAttr(o, u'key9')

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

            self.assertEquals(o.key3, u"drie")
            self.assertEquals(o._key4, u"viervierviervier")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testSetValueForKey(self):
            o = KeyValueClass2()

            self.assertEquals(o.key3, 3)
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'key3', u'drie')
            self.assertEquals(o.key3, u"drie")

            self.assertEquals(o._key4, u"4")
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'key4', u'vier')
            self.assertEquals(o._key4, u"viervierviervier")

            o.key5 = 1
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'key5', u'V')
            self.assertEquals(o.key5, u"VVVVV")

            self.assertNotHasAttr(o, u'key9')
            STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'key9', u'IX')
            self.assertHasAttr(o, u'key9')
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testValueForKey(self):
        o = KeyValueClass2()
        o.addMultiple()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key1"), 1)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key2"), 2)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key3"), 3)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"key4"), u"4")
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"multiple"), o.multiple)
        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, u"pythonConvention"), u'GOOD')

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_VALUEFORKEY, o, u"nokey")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_keyvalue.py View on Github external
def testValuesForKeys(self):
        o = KeyValueClass2()

        self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUESFORKEYS, 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_, DO_VALUESFORKEYS, o, [ u"key1", u"key2", u"nokey", u"key3" ])

pyobjc

Python<->ObjC Interoperability Module

MIT
Latest version published 22 days ago

Package Health Score

85 / 100
Full package analysis

Popular pyobjc functions

Similar packages