Steven D'Aprano wrote:

> D. Guandalino wrote:

>> In this case is there a
>> way to force just one setUp() call?
> 
> 
> I don't know if this is the best way, but the first way that comes to
> mind is this:
> 
> 
> class C(TestCase):
>      initialised = False
>      def setUp(self):
>          if self.initialised:
>              return
>          # Make sure you save the flag on the class, not the instance!
>          self.__class__.initialised = True
>          ...

Python 2.7 and 3.2 support setUpClass()/tearDownClass() classmethods, see

http://docs.python.org/library/unittest.html#unittest.TestCase.setUpClass

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to