Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
 def __init__(cls, name, bases, dct):
     super(MetaklassDctSaver, cls).__init__(name, bases, dct)
     cls.saved_dct = dct
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 def __new__(cls, *args, **kwargs):
     return super(OtherClass4, cls).__new__(cls, *args, **kwargs)
Пример #8
0
 def __init__(cls, name, bases, dct):
     super(MetaklassDctSaver, cls).__init__(name, bases, dct)
     cls.saved_dct = dct
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 def __new__(cls, *args, **kwargs):
     return super(OtherClass4, cls).__new__(cls, *args, **kwargs)