

@skip26
def test_classmethods(self):

    class C(object):

        def foo(*a):
            return a
        goo = classmethod(foo)
    c = C()
    self.assertEqual(C.goo(1), (C, 1))
    self.assertEqual(c.goo(1), (C, 1))
    self.assertEqual(c.foo(1), (c, 1))

    class D(C):
        pass
    d = D()
    self.assertEqual(D.goo(1), (D, 1))
    self.assertEqual(d.goo(1), (D, 1))
    self.assertEqual(d.foo(1), (d, 1))
    self.assertEqual(D.foo(d, 1), (d, 1))

    def f(cls, arg):
        return (cls, arg)
    ff = classmethod(f)
    self.assertEqual(ff.__get__(0, int)(42), (int, 42))
    self.assertEqual(ff.__get__(0)(42), (int, 42))
    self.assertEqual(C.goo.__self__, C)
    self.assertEqual(D.goo.__self__, D)
    self.assertEqual(super(D, D).goo.__self__, D)
    self.assertEqual(super(D, d).goo.__self__, D)
    self.assertEqual(super(D, D).goo(), (D,))
    self.assertEqual(super(D, d).goo(), (D,))
    meth = classmethod(1).__get__(1)
    self.assertRaises(TypeError, meth)
    try:
        classmethod(f, kw=1)
    except TypeError:
        pass
    else:
        self.fail("classmethod shouldn't accept keyword args")

dataset/ETHPy150Open PythonCharmers/python-future/tests/test_future/test_super.py TestSuperFromTestDescrDotPy.test_classmethods/original