This will do the same:
>>> Testcase.testName = testFunc
Yes, it really is that simple.
Your line
>>> instanceMethod = new.instancemethod(testFunc, None, TestCase)
Is in practice (albeit not theoretically) noop. :) You could just as well
>>> instanceMethod = testFunc
In fact, in Python 3, Iβm sure it will be the same in theory, but the new module has disappeared, so I canβt test it in practice.
Lennart Regebro
source share