def testSuperTest(self): c = DoubleInherit(1,2,3) self.assertEqual(super(DoubleInherit, c).get_y(), 2) c.y = 4 self.assertEqual(super(DoubleInherit, c).get_y(), 4) instance = super(MultiBase, MultiInherit1).__new__(MultiInherit1) self.assertEqual(instance.name, 'MultiInherit1') instance = super(MultiBase, MultiInherit1).__new__(MultiBase) self.assertEqual(instance.name, 'MultiBase') instance = super(MultiBase, MultiInherit1).__new__(MultiInherit1) instance.__init__(1,2) self.assertEqual(instance.x, 1) self.assertEqual(instance.y, 2) try: z = instance.z self.fail("failed to raise error for instance.z") except AttributeError, e: self.assertTrue(True)
def testSuperTest(self): c = DoubleInherit(1, 2, 3) self.assertEqual(super(DoubleInherit, c).get_y(), 2) c.y = 4 self.assertEqual(super(DoubleInherit, c).get_y(), 4) instance = super(MultiBase, MultiInherit1).__new__(MultiInherit1) self.assertEqual(instance.name, 'MultiInherit1') instance = super(MultiBase, MultiInherit1).__new__(MultiBase) self.assertEqual(instance.name, 'MultiBase') instance = super(MultiBase, MultiInherit1).__new__(MultiInherit1) instance.__init__(1, 2) self.assertEqual(instance.x, 1) self.assertEqual(instance.y, 2) try: z = instance.z self.fail("failed to raise error for instance.z") except AttributeError, e: self.assertTrue(True)
def __init__(cls, name, bases, dct): super(MetaklassDctSaver, cls).__init__(name, bases, dct) cls.saved_dct = dct
def __init__(self,a=None,b=None,c=None) : self.a3_args = [('a', a),('b',b),('c',c)] super(SuperArg3,self).__init__(a,b,c)
def __init__(self,a=None,b=None,c=None) : self.a2_args = [('a', a),('b',b),('c',c)] super(SuperArg2,self).__init__(a=a,b=b,c=c)
def __init__(self): # Cannot do RecurseMe._init__(self), that would really call myself # And we can only do this once... super(self.__class__, self).__init__() self.chain.append(1)
def __new__(cls, *args, **kwargs): return super(OtherClass4, cls).__new__(cls, *args, **kwargs)
def __init__(self, a=None, b=None, c=None): self.a3_args = [('a', a), ('b', b), ('c', c)] super(SuperArg3, self).__init__(a, b, c)
def __init__(self, a=None, b=None, c=None): self.a2_args = [('a', a), ('b', b), ('c', c)] super(SuperArg2, self).__init__(a=a, b=b, c=c)