def testCopyingWithSuperFromObjC(self): o = OC_CopyBase.alloc().init() self.assertFalse(o.copyWithZone_.isClassMethod) del o o = OC_TestCopy2.alloc().init() self.assertFalse(o.copyWithZone_.isClassMethod) del o o = OC_TestCopy3.alloc().init() self.assertFalse(o.copyWithZone_.isClassMethod) del o o = OC_TestCopy4.alloc().init() self.assertEquals(o.copyWithZone_.callable.occlass, "OC_TestCopy4") del o p = NSAutoreleasePool.alloc().init() o = OC_CopyHelper.doCopySetup_(OC_TestCopy2) del p self.assertEquals(o.x, 42) self.assertEquals(o.y, 24) self.assertEquals(o.intVal(), 40) p = NSAutoreleasePool.alloc().init() o = OC_CopyHelper.doCopySetup_(OC_TestCopy3) del p self.assertEquals(o.x, 42) self.assertEquals(o.y, 24) self.assertEquals(o.intVal(), 40) p = NSAutoreleasePool.alloc().init() o = OC_CopyHelper.doCopySetup_(OC_TestCopy4) del p self.assertEquals(o.x, 42) self.assertEquals(o.y, 24) self.assertEquals(o.z, "hello") self.assertEquals(o.intVal(), 40)
def testCopyingWithoutSuperFromObjC(self): v = OC_TestCopy1.alloc().init() self.assertFalse(v.copyWithZone_.isClassMethod) self.assertEquals(v.copyWithZone_.callable.occlass, "OC_TestCopy1") del v p = NSAutoreleasePool.alloc().init() o = OC_CopyHelper.doCopySetup_(OC_TestCopy1) del p self.assertEquals(o.x, 42) self.assertEquals(o.y, 24) self.assertRaises(AttributeError, getattr, o, 'z')