本文整理汇总了Python中PyObjCTest.testbndl.PyObjC_TestClass3类的典型用法代码示例。如果您正苦于以下问题:Python PyObjC_TestClass3类的具体用法?Python PyObjC_TestClass3怎么用?Python PyObjC_TestClass3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyObjC_TestClass3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCopy
def testCopy(self):
class MyCopyClass (NSObject):
def copyWithZone_(self, zone):
# NSObject doesn't implement the copying protocol
#o = super(MyCopyClass, self).copyWithZone_(zone)
o = self.__class__.alloc().init()
o.foobar = 2
return o
copyWithZone_ = objc.selector(
copyWithZone_,
signature=NSObject.copyWithZone_.signature,
isClassMethod=0)
# Make sure the runtime correctly marked our copyWithZone_
# implementation.
o = MyCopyClass.alloc().init()
self.assertFalse((o.copyWithZone_.__metadata__()['classmethod']))
self.assertTrue(o.copyWithZone_.__metadata__()['retval']['already_retained'])
#self.assertTrue(o.copyWithZone_.callable == MyCopyClass.__dict__['copyWithZone_'].callable)
o = MyCopyClass.alloc().init()
o.foobar = 1
self.assertEquals(o.foobar, 1)
# Make a copy from ObjC (see testbundle.m)
c = PyObjC_TestClass3.makeACopy_(o)
self.assertIsInstance(c, MyCopyClass)
self.assertEquals(c.foobar, 2)
示例2:
def testTakeValueForKey2(self):
o = KeyValueClass3()
self.assertEquals(o.foo, u"foobar")
STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, u'foo', u'FOO')
self.assertEquals(o.foo, u"FOO")
self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, DO_SETVALUE_FORKEY, o, u'key9', u'IX')
示例3:
def testTakeValueForKey2(self):
o = KeyValueClass3()
self.assertEqual(o.foo, "foobar")
STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, "foo", "FOO")
self.assertEqual(o.foo, "FOO")
self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, DO_SETVALUE_FORKEY, o, "key9", "IX")
示例4: testBaseValueForKey
def testBaseValueForKey(self):
self.assertEquals(DirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"directString"))
self.assertEquals(IndirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"indirectString"))
self.assertEquals(DirectNumber,
STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"directNumber"))
self.assertEquals(IndirectNumber,
STUB.keyValue_forObject_key_(DO_VALUEFORKEY, self.base, u"indirectNumber"))
示例5: testOverValueKeyPath
def testOverValueKeyPath(self):
self.assertEquals(DirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overDirectHead.directString"))
self.assertEquals(DirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overIndirectHead.directString"))
self.assertEquals(IndirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overDirectHead.indirectString"))
self.assertEquals(IndirectString,
STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, u"overIndirectHead.indirectString"))
示例6:
def testTakeValuesFromDictionary2(self):
o = KeyValueClass3()
self.assertEqual(o.foo, "foobar")
STUB.setKeyValue_forObject_key_value_(DO_TAKEVALUESFROMDICT, o, None, { 'foo': 'FOO' })
self.assertEqual(o.foo, "FOO")
self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, DO_TAKEVALUESFROMDICT, o, None, { 'key9': 'IX' })
self.assertRaises(KeyError, STUB.setKeyValue_forObject_key_value_, DO_TAKEVALUESFROMDICT, o, None, { 'roprop': 'IX' })
示例7: testValueForKeyPath
def testValueForKeyPath(self):
o = KeyValueClass2()
o.addMultiple()
self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple"), o.multiple)
self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2"), o.multiple.level2)
self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2.level3.keyA"), o.multiple.level2.level3.keyA)
self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, o, u"multiple.level2.level3.keyB"), o.multiple.level2.level3.keyB)
self.assertRaises(KeyError, STUB.keyValue_forObject_key_, DO_VALUEFORKEYPATH, o, u"multiple.level2.nokey")
示例8: testStoredValueForKey
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")
示例9: testPythonConvention
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')
示例10: testTakeValueForKeyPath
def testTakeValueForKeyPath(self):
o = KeyValueClass2()
o.addMultiple()
self.assertEqual(o.multiple.level2.level3.keyA, "hello")
self.assertEqual(o.multiple.level2.level3.keyB, "world")
STUB.setKeyValue_forObject_key_value_(DO_TAKEVALUE_FORKEYPATH, o, "multiple.level2.level3.keyA", "KeyAValue")
self.assertEqual(o.multiple.level2.level3.keyA, "KeyAValue")
STUB.setKeyValue_forObject_key_value_(DO_TAKEVALUE_FORKEYPATH, o, "multiple.level2.level3.keyB", 9.999)
self.assertEqual(o.multiple.level2.level3.keyB, 9.999)
示例11: testSetValueForKeyPath
def testSetValueForKeyPath(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_SETVALUE_FORKEYPATH, o, u"multiple.level2.level3.keyA", u"KeyAValue")
self.assertEquals(o.multiple.level2.level3.keyA, u"KeyAValue")
STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEYPATH, o, u"multiple.level2.level3.keyB", 9.999)
self.assertEquals(o.multiple.level2.level3.keyB, 9.999)
示例12: testPythonConvention
def testPythonConvention(self):
o = KeyValueClass2()
self.assertEqual(o._pythonConvention, "BAD")
self.assertEqual(o.pythonConvention(), "GOOD")
self.assertEqual(o._pythonConventionValue, "GOOD")
self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), "GOOD")
STUB.setKeyValue_forObject_key_value_(DO_SETVALUE_FORKEY, o, "pythonConvention", "CHANGED")
self.assertEqual(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, o, "pythonConvention"), "CHANGED")
self.assertEqual(o._pythonConvention, "BAD")
self.assertEqual(o.pythonConvention(), "CHANGED")
self.assertEqual(o._pythonConventionValue, "CHANGED")
示例13: testPathValueForKey
def testPathValueForKey(self):
self.assertEqual(
DirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.directString")
)
self.assertEqual(
DirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.directString")
)
self.assertEqual(
IndirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.indirectString")
)
self.assertEqual(
IndirectString, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.indirectString")
)
self.assertEqual(
DirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.directNumber")
)
self.assertEqual(
DirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.directNumber")
)
self.assertEqual(
IndirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "directHead.indirectNumber")
)
self.assertEqual(
IndirectNumber, STUB.keyValue_forObject_key_(DO_VALUEFORKEYPATH, self.path, "indirectHead.indirectNumber")
)
示例14: testStrCap
def testStrCap(self):
class Foo:
def callme(self):
return u"FOO"
# check the result for valueForKey: u"callme" on a Foo instance
self.assertEquals(STUB.keyValue_forObject_key_(DO_VALUEFORKEY, Foo(), u"callme"), u"FOO")
示例15: testSetValuesForKeysFromDictionary
def testSetValuesForKeysFromDictionary(self):
o = KeyValueClass2()
self.assertEqual(o.key3, 3)
self.assertEqual(o._key4, "4")
o.key5 = 1
self.assertNotHasAttr(o, "key9")
STUB.setKeyValue_forObject_key_value_(
DO_SETVALUESFORKEYSFROMDICT, o, None, {"key3": "drie", "key4": "vier", "key5": "V", "key9": "IX"}
)
self.assertEqual(o.key3, "drie")
self.assertEqual(o._key4, "viervierviervier")
self.assertEqual(o.key5, "VVVVV")
self.assertHasAttr(o, "key9")
self.assertEqual(o.key9, "IX")