예제 #1
0
 def testMakeAncestor1(self):
     cls = MixIn(self.pyClass, self.mixIn1, makeAncestor=True)
     self.assertEqual(cls.__bases__, (self.mixIn1, self.base))
     self.assertFalse(hasattr(cls, 'mixInsForPyClass'))
     self.assertFalse(hasattr(self.mixIn1, 'mixInSuperFoo'))
     self.assertEqual(cls.attr0, 'this is Base.attr0')
     self.assertEqual(cls.attr1, 'this is PyClass.attr1')
     self.assertEqual(cls.attr2, 'this is PyClass.attr2')
     self.assertEqual(cls.attr3, 'this is PyClass.attr3')
     self.assertEqual(cls.attr4, 'this is MixIn1.attr4')
     self.assertEqual(cls.cFoo(), 'this is PyClass.cFoo')
     self.assertEqual(cls.sFoo(), 'this is PyClass.sFoo')
     obj = cls()
     self.assertEqual(obj.foo(), 'this is PyClass.foo')
예제 #2
0
 def testMakeAncestor2(self):
     cls = MixIn(self.pyClass, self.mixIn2, makeAncestor=True)
     self.assertEqual(cls.__bases__, (self.mixIn2, self.base))
     self.assertFalse(hasattr(cls, 'mixInsForPyClass'))
     self.assertFalse(hasattr(self.mixIn2, 'mixInSuperFoo'))
     self.assertEqual(cls.attr0, 'this is Base.attr0')
     self.assertEqual(cls.attr1, 'this is PyClass.attr1')
     self.assertEqual(cls.attr2, 'this is PyClass.attr2')
     self.assertEqual(cls.attr3, 'this is PyClass.attr3')
     self.assertEqual(cls.attr5, 'this is MixIn2.attr5')
     self.assertEqual(cls.attr6, 'this is MixIn2.attr6')
     self.assertEqual(cls.cFoo(), 'this is PyClass.cFoo')
     self.assertEqual(cls.sFoo(), 'this is PyClass.sFoo')
     obj = cls()
     self.assertEqual(obj.foo(), 'this is PyClass.foo')
     self.assertEqual(obj.bar(), 'this is MixIn2.bar')
     self.assertEqual(obj.baz(), 'this is MixIn2Base.baz')