[SciPy-Dev] Generator tests
Sat Jul 14 09:17:58 CDT 2012
On Fri, Jul 13, 2012 at 11:57 AM, Pauli Virtanen <firstname.lastname@example.org> wrote:
> Ralf Gommers <ralf.gommers <at> googlemail.com> writes:
> > in the test or code. Plus, it once again shows how
> > annoying generator tests are; can't see which method is
> > failing.
> Here's a recommendation for generator test:
> - No computation related to the features tested should be
> done in the test_* generator function, but delegated to
> a corresponding _check_* function (can be inside the
> generator, to share namespace).
> - The generators should be used *solely* for loops over parameters.
> - These parameters should *not* be arrays.
> If a parameter is "complicated", as in the case of ARPACK
> tests, wrap it into a class with a descriptive __repr__ method.
> Like so:
> def test_foo():
> x = [1, 2, 3]
> z = 9
> def check(a, b):
> x = a + b + z
> y = a - b + z
> assert x == y + 2*b
> for a in [1, 2, 3]:
> for b in [4, 5, 6]:
> yield check, a, b
That's good advice. The ARPACK tests are a lot easier to deal with due to
doing it like this. We should also add the above to
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-Dev