How to use the pyobjc.pyobjc.pyobjc-framework-Cocoa.PyObjCTest.test_keyvalue.KeyValueClass1Explicit.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 = KeyValueClass1Explicit.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._values['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
    @max_os_level('10.5')
    def testTakeValueForKeyPath(self):
        o = KeyValueClass1Explicit.alloc().init()
        o.addMultiple()

        self.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyA'], u"hello")
        self.assertEqual(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.assertEqual(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.assertEqual(o._values['multiple']._values['level2']._values['level3']._values['keyB'], 9.999)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
    @max_os_level('10.5')
    def testTakeValuesFromDictionary(self):
        o = KeyValueClass1Explicit.alloc().init()

        self.assertEqual(o._values['key3'], 3)
        self.assertEqual(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.assertEqual(o._values['key3'], u"drie")
        self.assertEqual(o._values['key4'], u"viervierviervier")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testValueForKey(self):
        o = KeyValueClass1Explicit.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._values['multiple'])

        self.assertRaises(KeyError, STUB.keyValue_forObject_key_, 0, o, u"nokey")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testTakeValueForKey(self):
        o = KeyValueClass1Explicit.alloc().init()

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

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

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

        self.assert_(not hasattr(o, u'key9'))
        self.assert_('key9' not in o._values)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def addMultiple(self):
        self._values["multiple"] = KeyValueClass1Explicit.alloc().init()
        self._values["multiple"]._values["level2"] = KeyValueClass1Explicit.alloc().init()
        self._values["multiple"]._values["level2"]._values["level3"] = KeyValueClass1Explicit.alloc().init()
        self._values["multiple"]._values["level2"]._values["level3"]._values["keyA"] = u"hello"
        self._values["multiple"]._values["level2"]._values["level3"]._values["keyB"] = u"world"
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_keyvalue.py View on Github external
def testTakeStoredValueForKey(self):
        o = KeyValueClass1Explicit.alloc().init()

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

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

        o.key5 = 1
        STUB.setKeyValue_forObject_key_value_(2, o, u'key5', u'V')
        self.assertEqual(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)
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 = KeyValueClass1Explicit.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 = KeyValueClass1Explicit.alloc().init()
        o.addMultiple()

        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple"), o._values['multiple'])
        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple.level2"), o._values['multiple']._values['level2'])
        self.assertEqual(STUB.keyValue_forObject_key_(1, o, u"multiple.level2.level3.keyA"),
            o._values['multiple']._values['level2']._values['level3']._values['keyA'])
        self.assertEqual(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")

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