I am relatively new to Python. According to unittest.setUp documentation:
setUp()
Method called to prepare the test fixture. This is called immediately before calling the test method; any exception raised by this method will be considered an error rather than a test failure. The default implementation does nothing.
My question about setUp is as follows:
In our testing code base, I have seen that we customized the Python testing framework by inheriting from unittest.TestCase. Originally, unittest.TestCase has names setUp and tearDown.In the customized class, we have setUpTestCase and tearDownTestCase. So each time those two functions will be called instead of those original counterparts.
My questions are:
- How are those
setUpandtearDownfunctions being called by the underlying test runner? - Is it required that those functions used to set up test cases should start with
setUpand functions used to tear down test cases should start withtearDown? Or it can be named as any valid identifier?
Thank you.