Question

I have various python unitttest methods packed as a TestSuite, and one particular test method looks like e.g.

<input.MyTest testMethod=test_simple>

It looks like this is a class (the type of this thing is input.MyTest) but with an additional attribute(?) testMethod.

How can I extract the name test_simple from the attribute testMethod (or whatever this is)?

Test code (MyTest.py)

class MyTest(unittest.TestCase):
   def test_simple(self):
       pass

Suite code

from input import MyTest
suite = test.TestSuite()
suite.addTest(MyTest("test_simple"))
print suite._tests[0]
Was it helpful?

Solution

From a quick perusal of the documentation, you probably want to start with test.id()

id()

Return a string identifying the specific test case. This is usually the full name of the test method, including the module and class name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top