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

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable