def testCastFromMDerived3ToBases(self): '''MDerived3 is casted by C++ to its parents and the binding must return the MDerived3 wrapper.''' a = MDerived3() refcnt = sys.getrefcount(a) md1 = a.castToMDerived1() md2 = a.castToMDerived2() b1 = a.castToBase1() b2 = a.castToBase2() b3 = a.castToBase3() b4 = a.castToBase4() b5 = a.castToBase5() b6 = a.castToBase6() self.assert_(isinstance(md1, MDerived3)) self.assert_(isinstance(md2, MDerived3)) self.assert_(isinstance(b1, MDerived3)) self.assert_(isinstance(b2, MDerived3)) self.assert_(isinstance(b3, MDerived3)) self.assert_(isinstance(b4, MDerived3)) self.assert_(isinstance(b5, MDerived3)) self.assert_(isinstance(b6, MDerived3)) self.assertEqual(a, md1) self.assertEqual(a, md2) self.assertEqual(a, b1) self.assertEqual(a, b2) self.assertEqual(a, b3) self.assertEqual(a, b4) self.assertEqual(a, b5) self.assertEqual(a, b6) self.assertEqual(sys.getrefcount(a), refcnt + 8)
def testCastFromMDerived3ToBase3(self): '''MDerived3 is casted by C++ to Base3 grandparent using both the inherited and reimplement castToBase3 methods.''' a = MDerived3() refcnt = sys.getrefcount(a) b3_reimplemented = a.castToBase3() b3_inherited = MDerived2.castToBase3(a) self.assert_(isinstance(b3_reimplemented, MDerived3)) self.assert_(isinstance(b3_inherited, MDerived3)) self.assertEqual(a, b3_reimplemented) self.assertEqual(a, b3_inherited) self.assertEqual(sys.getrefcount(a), refcnt + 2)