A way to output pyunit test name in setup()
self.id().split('.')[-1]
You can find the Documentation at: http://docs.python.org/library/unittest.html#unittest.TestCase.id
edit: For 2.7 users, https://docs.python.org/2.7/library/unittest.html#unittest.TestCase.id
You can use self._testMethodName
. This is inherited from the unittest.TestCase
parent class.
def setUp():
print("In method", self._testMethodName)