How to optimise this code?
basilisk96 at gmail.com
Wed Aug 22 04:39:45 CEST 2007
If your true design intent is to run X number of test cases, unittest
is the biggest bang for your buck, like shown by Peter's example. You
just subclass unittest.TestCase, and def your test methods in the
class body; they will simply be executed in the order you list them.
It's just nice how it works that way.
Otherwise, the function factory approach like Hrvoje's
functionToCall = getattr(self, "testCase%s" % tc)
is the best optimization.
More information about the Python-list