I feel like I should know this, but I haven’t been able to figure it out…
I want to get the name of a method–which happens to be an integration test–from inside it so it can print out some diagnostic text. I can, of course, just hard-code the method’s name in the string, but I’d like to make the test a little more DRY if possible.
The answers involving introspection via
inspectand the like are reasonable. But there may be another option, depending on your situation:If your integration test is written with the unittest module, then you could use
self.id()within your TestCase.