On Wed, Dec 9, 2009 at 6:04 AM, Michael Droettboom <md...@stsci.edu> wrote: > Sorry, just commenting on the parts I feel competent in :) But I think > this is a great improvement. It would be nice to start doing doctests > as a matter of course to keep the docs accurate. >
Indeed. From the sidelines, thanks a lot to Paul for this work! Speaking of testing, here's a bit of code that I've had for a while pending for ipython, but which I think could be very useful for numpy too. Feel free to rip only the parts you need... The point of this code is to get a few nose-style features that produce normal unittests. In particular, it introduces support for single functions to be tests (something nose does but unittest doesn't), and most importantly, parametric tests that can be debugged meaningfully. A simple example: def is_smaller(i,j): assert i<j,"%s !< %s" % (i,j) class Tester(ParametricTestCase): def test_parametric(self): yield is_smaller(3, 4) x, y = 1, 2 yield is_smaller(x, y) @parametric def test_par_standalone(): yield is_smaller(3, 4) x, y = 1, 2 yield is_smaller(x, y) Both the class-based and the function-based tests are parametric. The key difference with nose is that you do yield assertion(values) instead of yield (assertion, values) When the test suite executes, it's calling *your* code, and if the test fails, the stack you end up inspecting is your stack. With nose, you return the unevaluated arguments assertion and nose calls it later. If the test fails, you're stuck debugging inside the nose stack, with no useful information about your test other than the values, and your original stack is gone. I hope this helps those writing numpy/scipy tests. Cheers, f
lightunit.tgz
Description: GNU Zip compressed data
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion