A Way To Output Pyunit Test Name In Setup()


Answer :

You can use self._testMethodName. This is inherited from the unittest.TestCase parent class.

def setUp():     print "In method", self._testMethodName 

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 usestr(self.id()).split()[4]. It could be found here http://docs.python.org/library/unittest.html#unittest.TestCase.id


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?