Re: How to optimise this code?

2007-08-22 Thread Bruno Desthuilliers
David N Montgomery a écrit : > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.testCase5() > if tc == 6:self.testCa

Re: How to optimise this code?

2007-08-22 Thread Hyuga
On Aug 22, 4:52 am, "David N Montgomery" <[EMAIL PROTECTED]> wrote: > 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 'f

Re: How to optimise this code?

2007-08-22 Thread David N Montgomery
On Wed, 22 Aug 2007 02:39:45 -, "Basilisk96" <[EMAIL PROTECTED]> said: > David, > > 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

Re: How to optimise this code?

2007-08-21 Thread Basilisk96
David, 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 h

Re: How to optimise this code?

2007-08-21 Thread Wayne Brehaut
On Tue, 21 Aug 2007 21:56:18 +0200, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: >Christof Winter <[EMAIL PROTECTED]> writes: > >> To get rid of the if statements, replace __init__ function with: >> >> def __init__(self, tc): >> functionToCall = eval("self.testCase%s" % tc) > >Or functio

Re: How to optimise this code?

2007-08-21 Thread Hrvoje Niksic
Christof Winter <[EMAIL PROTECTED]> writes: > To get rid of the if statements, replace __init__ function with: > > def __init__(self, tc): > functionToCall = eval("self.testCase%s" % tc) Or functionToCall = getattr(self, "testCase" + tc) eval can introduce unwanted side effects. --

Re: How to optimise this code?

2007-08-21 Thread Christof Winter
David N Montgomery wrote: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.testCase5() > if tc == 6:self.testCase6

Re: How to optimise this code?

2007-08-21 Thread Nils Oliver Kröger
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David N Montgomery schrieb: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:sel

Re: How to optimise this code?

2007-08-21 Thread Dustan
On Aug 21, 11:20 am, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > I suspect lambda might be your friend here too for making the code less > verbose, though I never really got the hang of lambdas, even though my > first programming experience was a scheme class way back when Ah well. That's be

Re: How to optimise this code?

2007-08-21 Thread J. Cliff Dyer
David N Montgomery wrote: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.testCase5() > if tc == 6:self.testCase6

Re: How to optimise this code?

2007-08-21 Thread Peter Otten
David N Montgomery wrote: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.testCase5() > if tc == 6:self.testCase

Re: How to optimise this code?

2007-08-21 Thread kyosohma
On Aug 21, 10:59 am, "David N Montgomery" <[EMAIL PROTECTED]> wrote: > class testCase: > def __init__(self, tc): > if tc == 1:self.testCase1() > if tc == 2:self.testCase2() > if tc == 3:self.testCase3() > if tc == 4:self.testCase4() > if tc == 5:self.test

How to optimise this code?

2007-08-21 Thread David N Montgomery
class testCase: def __init__(self, tc): if tc == 1:self.testCase1() if tc == 2:self.testCase2() if tc == 3:self.testCase3() if tc == 4:self.testCase4() if tc == 5:self.testCase5() if tc == 6:self.testCase6() def testCase1(self): print