I am writing unit tests and have the following structure:
class TestSuite(unittest.TestCase, HelperClass):
@classmethod
def setUpClass(cls):
# I want to use methods from HelperClass here, but get errors
# I have tried cls.method_name() and self.method_name()
def setUp(self):
self.method_name() # methods from HelperClass work here
...
As noted in my comments, I'd like to use some validation methods from HelperClass in my setUpClass method, but if I try to call with cls.method_name(), I get TypeError: method_name() missing 1 required positional argument: 'self'
, but if I use self.method_name(), I get NameError: name 'self' is not defined
.
This is probably something pretty basic, but I'm just not sure the correct search term I'm supposed to use to find the answer. The unittest documentation on setUpClass doesn't get into it either, unfortunately.