cls.__name__
is always the name of the current class, because cls
is bound the actual class object on which the class method was called.
In other words, cls
is not a reference to the class on which the method is defined.
Note that you should not use super(cls, cls)
! That'll lead to infinite recursion if you were to create a derived class from MyTestCase
! Use the actual class, always:
class MyTestCase(BaseTestCase):
@classmethod
def setUpClass(cls):
# Call SetUpClass from parent (BaseTestCase)
super(MyTestCase, cls).setUpClass()
# Do more stuff...
Demo:
>>> class Foo(object):
... @classmethod
... def spam(cls):
... print(cls.__name__)
...
>>> class Bar(Foo):
... @classmethod
... def spam(cls):
... super(Bar, cls).spam()
...
>>> Bar.spam()
Bar
>>> Foo.spam()
Foo