[SciPy-dev] Making numpy test work in scikits

Matthieu Brucher matthieu.brucher@gmail....
Fri Jul 20 02:34:55 CDT 2007


Hi,

I have to say that the fact that not all test_*.py are parsed for tests
annoys me in Numpy. If you want to test a file something.py, you have to
create a tests/test_something.py, you can't use an other name. And when you
want to test more than just a part of your code - like for the optimizers, I
want to test several modules together -, those tests are not part of the
test suite that Numpy creates.
Thus, I created a file that executes all test_*.py, but it cannot work with
setuptools.

But I thought that this worked (I think I've used it before) :

def test():
  from numpy.testing import NumpyTest
  return NumpyTest().test()

in the __init__.py of a module that must be tested, doesn't it ?

Matthieu

2007/7/20, David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
>
> Hi,
>
>     I had a hard time to get the usual numpy tests working inside a
> scikits (because of setuptools): I wanted to keep the usual numpy tests
> infrastructure (each package has a tests directory where all the tests
> are), while being able to use them with python setup.py test. Below is a
> an quick explanation how I did it:
>
>     - foo/scikits/foo  -> this  is a typical "scipy package", in the
> sense that you can use the same layout for tests  as in a scipy package.
>     - foo/setup.py -> use the test_suite argument of the setup function,
> with the value "tester"
>     - foo/tester.py -> this defines a function additional_tests, which
> is supposed to return a unittest.TestSuite. I use NumpyTest to find all
> the tests in the package foo, and make a TestSuite from it; I had to use
> a private function, though, but maybe adding public API in numpy would
> be possible. The module tester boils down to this:
>
> from numpy.testing import NumpyTest
>
> def additional_tests():
>     # XXX: does this guarantee that the package is the one in the dev
> trunk, and
>     # not scikits.foo installed somewhere else ?
>     import scikits.foo
>     np = NumpyTest(scikits.foo)
>     return np._test_suite_from_all_tests(np.package, level = 1,
> verbosity = 1)
>
> With this, you can call all the tests with python setup.py test (which
> is the point of all this, actually), but:
>     - I don't know much about unittest, though, so this may be not ideal
> but is the only way I found to make is work without touching anything
> else than the setup.py file.
>     - There may be a way to make this a bit more automatic (I don't like
> the fact that I have to give the name of the package in
> additional_tests, for example)
>     - I didn't find a way to give argumements for tests in command line
> (setuptools does not seem to support it for the test command).
>
>     cheers,
>
>     David
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20070720/e6e737dc/attachment-0001.html 


More information about the Scipy-dev mailing list