aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding/multiple_derived_test.py
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-12 09:48:17 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-18 09:22:50 -0300
commit80282277d0845a65739c33675aa9a91b10faa4b1 (patch)
treef4dd29f1e781aedae883e9e96e958fd213072b98 /tests/samplebinding/multiple_derived_test.py
parent75988e117f22d6bd228dc3fa54887bfcf3773b00 (diff)
improved multiple inheritance tests with a myriad of new cases
Diffstat (limited to 'tests/samplebinding/multiple_derived_test.py')
-rwxr-xr-xtests/samplebinding/multiple_derived_test.py82
1 files changed, 50 insertions, 32 deletions
diff --git a/tests/samplebinding/multiple_derived_test.py b/tests/samplebinding/multiple_derived_test.py
index 473cf8da0..f42ede30f 100755
--- a/tests/samplebinding/multiple_derived_test.py
+++ b/tests/samplebinding/multiple_derived_test.py
@@ -29,55 +29,73 @@
import sys
import unittest
-from sample import MBase1, MBase2, MDerived
+from sample import Base1, Base2, Base3, Base4, Base5, MDerived1, MDerived2, MDerived3
class MultipleDerivedTest(unittest.TestCase):
'''Test cases for multiple inheritance'''
def testIsInstance(self):
- '''MDerived is instance of its parents MBase1 and MBase2.'''
- a = MDerived()
- self.assert_(isinstance(a, MDerived))
- self.assert_(isinstance(a, MBase1))
- self.assert_(isinstance(a, MBase2))
+ '''MDerived1 is instance of its parents Base1 and Base2.'''
+ a = MDerived1()
+ self.assert_(isinstance(a, MDerived1))
+ self.assert_(isinstance(a, Base1))
+ self.assert_(isinstance(a, Base2))
def testIsSubclass(self):
- '''MDerived is subclass of its parents MBase1 and MBase2.'''
- self.assert_(issubclass(MDerived, MBase1))
- self.assert_(issubclass(MDerived, MBase2))
+ '''MDerived1 is subclass of its parents Base1 and Base2.'''
+ self.assert_(issubclass(MDerived1, Base1))
+ self.assert_(issubclass(MDerived1, Base2))
- def testCallToFunctionWithMBase1ArgumentThatCastsBackToMDerived(self):
- '''MDerived is passed as an MBase1 argument to method that returns it casted back to MDerived.'''
- a = MDerived()
- b = MDerived.transformFromBase1(a)
+ def testCallToFunctionWithBase1ArgumentThatCastsBackToMDerived1(self):
+ '''MDerived1 is passed as an Base1 argument to method that returns it casted back to MDerived1.'''
+ a = MDerived1()
+ b = MDerived1.transformFromBase1(a)
self.assertEqual(a, b)
- def testCallToFunctionWithMBase2ArgumentThatCastsBackToMDerived(self):
- '''MDerived is passed as an MBase2 argument to method that returns it casted back to MDerived.'''
- a = MDerived()
- b = MDerived.transformFromBase2(a)
+ def testCallToFunctionWithBase2ArgumentThatCastsBackToMDerived1(self):
+ '''MDerived1 is passed as an Base2 argument to method that returns it casted back to MDerived1.'''
+ a = MDerived1()
+ b = MDerived1.transformFromBase2(a)
self.assertEqual(a, b)
- def testCastFromMDerivedToMBase1(self):
- '''MDerived is casted by C++ to its first parent MBase2 and the binding must return the MDerived wrapper.'''
- a = MDerived()
+ def testCastFromMDerived1ToBase1(self):
+ '''MDerived1 is casted by C++ to its first parent Base2 and the binding must return the MDerived1 wrapper.'''
+ a = MDerived1()
refcnt = sys.getrefcount(a)
- b = a.castToMBase1()
- self.assert_(isinstance(b, MDerived))
+ b = a.castToBase1()
+ self.assert_(isinstance(b, MDerived1))
self.assertEqual(a, b)
self.assertEqual(sys.getrefcount(a), refcnt + 1)
- """
- # This method must be commented since it will break the test flow until the problem is fixed.
- def testCastFromMDerivedToMBase2(self):
- '''MDerived is casted by C++ to its second parent MBase2 and the binding must return the MDerived wrapper.'''
- a = MDerived()
+ def testCastFromMDerived1ToBases(self):
+ '''MDerived1 is casted by C++ to its parents and the binding must return the MDerived1 wrapper.'''
+ a = MDerived1()
refcnt = sys.getrefcount(a)
- b = a.castToMBase2()
- self.assert_(isinstance(b, MDerived))
- self.assertEqual(a, b)
- self.assertEqual(sys.getrefcount(a), refcnt + 1)
- """
+ b1 = a.castToBase1()
+ b2 = a.castToBase2()
+ self.assert_(isinstance(b1, MDerived1))
+ self.assert_(isinstance(b2, MDerived1))
+ self.assertEqual(a, b1)
+ self.assertEqual(a, b2)
+ self.assertEqual(sys.getrefcount(a), refcnt + 2)
+
+ 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)
if __name__ == '__main__':
unittest.main()