I have overridden the unittest.TestCase class to include some additional functionality like this
class TestCase(unittest.TestCase):
def foo(self):
return 4711
which I am going to use in the setUpClass
call in a Test Case like this
class MyTest(TestCase):
@classmethod
def setUpClass(cls):
value = cls.foo() #1
value = MyTest.foo() #2
value = MyTest().foo() #3
value = TestCase().foo() #4
where I fail to access the function foo()
I have implemented in the modified unitest class.
I can see that try #2 will fail because I try to access a method of a class which is not instantiated, and foo is not a classmethod.
I can see that try #1 also does not work, as I am trying to access a non-class method from the classmethod level (or how this ever is correctly described).
But why is try #3/#4 giving me an no such test method
error?
How is it possible to access the foo()
method WITHOUT making it a classmethod (because I cannot change this as it is something external)?