[SciPy-dev] Two new test failures

Pauli Virtanen pav@iki...
Thu Nov 13 14:03:27 CST 2008


Thu, 13 Nov 2008 14:28:33 -0500, josef.pktd wrote:
[clip]
> I have problems making my nose tests more complex. All my tests are
> based on test generators with yield.
>
>
> I did not manage to get the test generators to work inside a TestCase
> class and using fixtures but I managed to work around that. I added a
> seed for the random number generator to my test function so now I get
> deterministic results.

Nose indeed has some problems with test generators in classes inherited 
from TestCase. This is probably a bug in Nose.

If you don't need the self.* methods available in a 'TestCase' class, you 
can base the class on 'object' instead. Nose still finds the tests in it, 
and the generators start to work.

> The problem, I still didn't manage to figure out, is how and whether the
> knownfailureif decorator works with test generators, e.g.
> 
> this is my test:
> 
> @dec.knownfailureif(True, "This test is known to fail") def
> test_discrete_rvs_cdf_fail():
[clip]
>         yield check_discrete_chisquare, distname, arg
[clip]
> I get an error instead of a known failure which is not counted towards
> failures and errors.
> 
> Is there a trick to get the decorators to work with generators or is
> this not possible?

I think it will work if the decorators are applied to the _check methods 
instead. But this seems like a bug in Nose -- it should catch SkipTest 
raised already in the generator method, not only in functions yielded by 
it.

-- 
Pauli Virtanen



More information about the Scipy-dev mailing list