[Numpy-discussion] [numpy.testing] re-import when using coverage

Fabrice Silva silva at lma.cnrs-mrs.fr
Wed May 16 11:05:48 EDT 2012

I am getting into troubles when using numpy.testing with coverage. A
minimal example package is atached to this email. Unpack and run:

$ python -c "import mypackage; mypackage.test(verbose=10,coverage=False)"
$ python -c "import mypackage; mypackage.test(verbose=10,coverage=True)"

Some explanations:
This package contains two module files, one of them (b.py) defining a
class (mycls), the other one (a.py) importing the first module. I then
add a simple test file, that does instantiate the class through the
other module (a.py) and checking the type of the resulting object
against b.mycls
Without coverage, everything is ok. With coverage, I got a
(unexpected ?) reload of the modules, leading to a mismatch of types...

The real case is somewhat more complicated, and I would prefer to keep
the instantiation through a.py. Is there a way to solve the problem ?

Best regards

Fabrice Silva <silva at lma.cnrs-mrs.fr>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mypackage.tar
Type: application/x-tar
Size: 10240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120516/24da53da/attachment.tar>

More information about the NumPy-Discussion mailing list