After reading How to get the function name as string in Python?
I wondered if it is somehow possible to put a logging statement into one of the
def setUp(self):
...
def tearDown(self):
...
and print the name of the current test function.
Testcases have a self.id() method that returns the current TestClassName.testMethodName.
The method uses self._testMethodName to build that string; you could use that attribute but the name of the attribute does flag it as internal. Relying on the attribute being there may not work in all Python versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With