[Numpy-discussion] running numpy tests

Robert Kern robert.kern@gmail....
Mon Aug 4 21:19:52 CDT 2008


On Mon, Aug 4, 2008 at 20:41, Andrew Dalke <dalke@dalkescientific.com> wrote:
> On Aug 5, 2008, at 2:00 AM, Robert Kern wrote:
>> You have old stuff in your checkout/installation. Make sure you have
>> deleted all of the *.pycs and directories which have been deleted in
>> SVN.
>
> Now that I've fixed that, I can tell that I made a
> mistake related to the self-test code.  I can't figure
> it out.
>
> Many of the modules have code which look like
>
>     from testing import Tester
>     test = Tester().test
>     bench = Tester().bench
>
> As I understand it, this code is migrating to use nosetests.
> Because people expect 'import numpy; numpy.test()' to work,
> there will be a compatibility period where this API is
> unchanged.
>
> I found that importing 'testing' costs 0.013 seconds, which
> is 10% of my current import time.  I would like to defer
> the import until needed, so I rewrote the 'test' code as:
>
>     def test(label='fast', verbose=1, extra_argv=None, doctests=False,
>              coverage=False, **kwargs):
>         from testing import Tester
>         import numpy
>         Tester(numpy).test(label, verbose, extra_argv, doctests,
>                            coverage, **kwargs)
>
>
> In my view there's no difference between them, but Tester().test does
> introspection to figure out the module location.  (In fact, if I
> don't pass it the module explicitly then it expects that locals()
> ["__file__"] for sys._getframe(-1) will exist, which is not the case
> with my function.  The underling code should instead check for that
> variable in globals().)

Probably. Or take a level= argument to tell _getframe() to go up an
extra level. Or both.

> I ended up with recursion errors, and I don't know why.  Any idea of
> what to do?

Ah. My guess is that the test collector sees numpy.test() as a
function that matches its regex for a unit test. It used to be a bound
method, so I think nose ignored it, then. You should be able to tell
nose not to collect it like so:

def test(...):
    ...
test.__test__ = False

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list