On Thu, Apr 23, 2009 at 9:00 AM, Philippe Fremy <p...@freehackers.org> wrote:
>
> Hi,
>
> I am getting "(inconsistently failed then succeeded)" which are quite
> annoying. It's for code that checks conditions maniuplated by threads:
>
>        t = threading.Thread( target=checker.start, args=(elcConfig,
> result)  )
>        t.start()
>
>        time.sleep( 0.1 )
>
>        checker.stop( False )
>
>        if not t.isAlive(): assert False
>
>        if checker.isFinished(): assert False
>
>
>
>        checker.join()
>
>>       if t.isAlive(): assert False
>
> E       AssertionError: (inconsistently failed then succeeded)
>
>
> I am playing a bit with race conditions here, but should that be a
> reason for my test to fail ? The conditions that I am checking arrive in
> the right order, only py.test is complaining.
>
> Any way I can get rid of "(inconsistently failed then succeeded)" ?
>
> cheers,
>
> Philippe

Philippe,

I have found that storing the results of the call I want to test the
result of, and then asserting the result generally eliminates these
errors.

For example:

assert Foo() == 23

often caused me problems with that message, however:

foo = Foo()
assert foo == 23

would not.

I am not sure why that is the case but I was able to resolve the issue
using the second form.

Hope that helps.

-- 
Stand Fast,
tjg.  [Timothy Grant]
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to