[SciPy-dev] Making numpy test work in scikits

Matthieu Brucher matthieu.brucher at gmail.com
Tue Jul 24 03:41:05 EDT 2007


>
> It is intended if you read the docstring (I totally missed it too, at
> first). If level is negative, then it is equivalent to returning all the
> test corresponding to abs(level) in a test suite, without running them.


Yes, I read it, but it does not find tests at all for instance :

  Found 0 tests for Components.IO.ipb.tests.test_ipbreader
  Found 0 tests for Components.IO.nifti.tests.test_niftiimage

instead of :

  Found 8 tests for Components.IO.ipb.tests.test_ipbreader
  Found 3 tests for Components.IO.nifti.tests.test_niftiimage

 for a positive level.

As I do not want to run the tests, just the testsuite, I passed level
> -10 (which is supposed to return all the tests at all level, if I
> understand correctly). I agree this is not really intuitive.



The problem is that it returns an empty test suite (I pass it to a
TextTestRunner instance, like in the example on python.org, but nothing
happens)


> Are you aware of set_local_path ? I used it when I need to use the same
> function/global variables accross several test files. You can see an
> example in the learn scikits (scikits/learn/machine/em/test_densities).
>
> set_local_path()
> # import modules that are located in the same directory as this file.
> from testcommon import DEF_DEC
> restore_path()
>
> This is basically a hack to put the current path (or any other relative
> path you give to set_local_path function) in sys.path so that they are
> found by the python interpreter.


Thank you for the explanation on this one, but I can't use it, I need to
modify os.cwd so that it points to the correct path. In fact what I do is
create a subprocess for each test file as if it was started from its parnet
folder. This way, I do not have to write
load('folder1/folder2/folder3/tests/mydata'), only load('mydata'). I could
put everything in a global ata folder, but if I want only to execute the
tests in a specific file, I would not be able to do so, because os.cwd is
different. But I don't think there is a solution to this problem anyway.

Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20070724/df4195d3/attachment.html>


More information about the SciPy-Dev mailing list