Пример #1
0
 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)
 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)
Пример #3
0
 def testCastFromMDerived2ToBases(self):
     '''MDerived2 is casted by C++ to its parents and the binding must return the MDerived2 wrapper.'''
     a = MDerived2()
     refcnt = sys.getrefcount(a)
     b3 = a.castToBase3()
     b4 = a.castToBase4()
     b5 = a.castToBase5()
     b6 = a.castToBase6()
     self.assert_(isinstance(b3, MDerived2))
     self.assert_(isinstance(b4, MDerived2))
     self.assert_(isinstance(b5, MDerived2))
     self.assert_(isinstance(b6, MDerived2))
     self.assertEqual(a, b3)
     self.assertEqual(a, b4)
     self.assertEqual(a, b5)
     self.assertEqual(a, b6)
     self.assertEqual(sys.getrefcount(a), refcnt + 4)