How to use the pyobjc.pyobjc.pyobjc-framework-Cocoa.PyObjCTest.test_keyvalue.KeyValueClass1.alloc 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-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testStoredValueForKey(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

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

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 2, o, u"nokey")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def addMultiple(self):
        self.multiple = KeyValueClass1.alloc().init()
        self.multiple.level2 = KeyValueClass1.alloc().init()
        self.multiple.level2.level3 = KeyValueClass1.alloc().init()
        self.multiple.level2.level3.keyA = u"hello"
        self.multiple.level2.level3.keyB = u"world"
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testValueForKey(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

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

        self.assertEqual(STUB.keyValue_forObject_key_(0, o, u"key2"), 2)
        self.assertEqual(STUB.keyValue_forObject_key_(0, o, u"key3"), 3)
        self.assertEqual(STUB.keyValue_forObject_key_(0, o, u"key4"), "4")
        self.assertEqual(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,
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
    @max_os_level('10.5')
    def testTakeValueForKey(self):
        o = KeyValueClass1.alloc().init()

        self.assertEqual(o.key3, 3)
        STUB.setKeyValue_forObject_key_value_(0, o, u'key3', u'drie')
        self.assertEqual(o.key3, u"drie")

        self.assertEqual(o._key4, u"4")
        STUB.setKeyValue_forObject_key_value_(0, o, u'key4', u'vier')
        self.assert_(not hasattr(o, u"key4"))
        self.assertEqual(o._key4, u"viervierviervier")

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

        self.assert_(not hasattr(o, u'key9'))
        STUB.setKeyValue_forObject_key_value_(0, o, u'key9', u'IX')
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
    @max_os_level('10.5')
    def testTakeValueForKeyPath(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

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

        STUB.setKeyValue_forObject_key_value_(1, o, u"multiple.level2.level3.keyA", u"KeyAValue")
        self.assertEqual(o.multiple.level2.level3.keyA, u"KeyAValue")

        STUB.setKeyValue_forObject_key_value_(1, o, u"multiple.level2.level3.keyB", 9.999)
        self.assertEqual(o.multiple.level2.level3.keyB, 9.999)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testNoPrivateVars(self):
        # Private instance variables ('anObject.__value') are not accessible using
        # key-value coding.
        o = KeyValueClass1.alloc().init()
        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o, u"private")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testTakeStoredValueForKey(self):
        o = KeyValueClass1.alloc().init()

        self.assertEqual(o.key3, 3)
        STUB.setKeyValue_forObject_key_value_(2, o, u'key3', u'drie')
        self.assertEqual(o.key3, u"drie")

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

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

        self.assert_(not hasattr(o, u'key9'))
        STUB.setKeyValue_forObject_key_value_(2, o, u'key9', u'IX')
        self.assert_(hasattr(o, u'key9'))
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
    @max_os_level('10.5')
    def testValuesForKeys(self):
        o = KeyValueClass1.alloc().init()

        self.assertEqual(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"])
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testValueForKeyPath(self):
        o = KeyValueClass1.alloc().init()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple"), o.multiple)
        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple.level2"), o.multiple.level2)
        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple.level2.level3.keyA"),
            o.multiple.level2.level3.keyA)
        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple.level2.level3.keyB"),
            o.multiple.level2.level3.keyB)

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 1, o, u"multiple.level2.nokey")

pyobjc

Python<->ObjC Interoperability Module

MIT
Latest version published 5 months ago

Package Health Score

82 / 100
Full package analysis

Popular pyobjc functions

Similar packages