[Tutor] Unit testing

Tino Dai tinoloc at gmail.com
Wed Jun 28 23:04:35 CEST 2006


On 6/27/06, Kent Johnson <kent37 at tds.net> wrote:
>
> Tino Dai wrote:
> >     How I have it now:
> >
> >     semaA = threading.semaphore()
> >
> >     class nameA:
> >        def __init__(self):
> >             <do some stuff>
> >
> >        def run(self):
> >              <do some stuff>
> >              semaA.release()
> >
> >     class nameB:
> >        def __init__(self):
> >             <do some stuff>
> >
> >        def run(self):
> >              semaA.acquire()
> >              <do some stuff>
> >
> >
> >     Does that make sense. Or is there a better way?
>
> class nameA:
>    def __init__(self, sema):
>         self.sema = sema
>         <do some stuff>
>
>    def run(self):
>          <do some stuff>
>          self.sema.release()
>
> class nameB:
>    def __init__(self, sema):
>         self.sema = sema
>         <do some stuff>
>
>    def run(self):
>          self.semaA.acquire()
>          <do some stuff>
>
>
> In the client code or the unit test:
> semaA = threading.semaphore()
> anA = nameA(semaA)
> aB = nameB(semaA)
> anA.run()
> aB.run()


I got it. I guess it doesn't work like regular variables! Thanks! -Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060628/70e9a8df/attachment.htm 


More information about the Tutor mailing list