How to optimise this code?
David N Montgomery
monty.python at fastmail.fm
Wed Aug 22 10:52:06 CEST 2007
On Wed, 22 Aug 2007 02:39:45 -0000, "Basilisk96" <basilisk96 at gmail.com>
> 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.
Thank you all - the assistance is much appreciated.
unittest is the best choice for my needs and works perfectly in Eclipse.
Unfortunately though it (and many other things) does not work under the
application we have to use to run our python scripts.
This leaves me with 'functionToCall = getattr(self, "testCase%s" % tc)'.
This achieves the optimisation/simplification I had been looking for.
Thank you once again.
More information about the Python-list