Repository navigation
Description
In scikit-image we are experiencing an issue with the documentation testing due to conftest.py discovery issues on Windows (we use Windows VMs on AppVeyor and Azure).
Basically, the structure of our testing env is the following:
skimage/
- subpackage0/
--- tests/...
--- (modules)
...
- subpackageN/
--- tests/...
--- (modules)
- setup.py
- conftest.py
Once the package is installed, we run the testing from another directory as follows:
export TEST_ARGS="-v --doctest-modules --cov=skimage"
pytest ${TEST_ARGS} --pyargs skimage
For an example of the (failing) build, see https://dev.azure.com/scikit-image/scikit-image/_build/results?buildId=344.
For Linux and MacOS builds on Travis-CI we use essentially the same scripts. However, it seems that the conftest.py file at the rootdir of the package is correctly located and taken into account, what makes us think that the issue is Windows-specific.
Please, let me know if you need any additional debugging info.
- a detailed description of the bug or suggestion
- *output of
pip listfrom the virtual environment you are using: see the Azure link above -> section "Pre-testing" - pytest and operating system versions: pytest 4.4.1
- minimal example if possible: sorry, I don't have a Windows machine for this
Activity
nicoddemus commentedon May 1, 2019
Hi @soupault,
I'm seeing failures like this:
Is this what you refer to?
soupault commentedon May 1, 2019
Hi @nicoddemus ,
Thank you for the prompt response!
Yes. Basically, in our
conftest.pywe fix numpy printoptions to "legacy" format (there are few more things, but they are not relevant). Those failing tests indicate that the printoptions have not been set (i.e. numpy is using the new formatting), what, in its turn, means that the conftest.py has not been found and/or properly used.For more information on numpy printoptions, see https://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html (-> argument
legacy) or numpy 1.14 release notes.nicoddemus commentedon May 1, 2019
Hi @soupault,
I've been able to reproduce the issue locally by following the Azure build script. Using the debugger I've found out:
conftest.pyis being discovered and imported as expected. I can seenp.set_printoptions()being called.no.get_printoptions()is returning the expected values just prior to calling the doctest.I've added the following code to ensure this:
(this is the pytest code which executes the doctests)
As expected the assertion works. I've also changed that string to something else for sanity check, and all tests fail then as expected. This can be easily verified by adding this to any of the failing doctests:
This assertion passes for me on failing doctests (again for sanity check we can change the
"1.13"string to something else, say"FOO", and then we see the assertion failing).Given the above, I'm not sure what's happening here,
numpy's print options seem to be set to the correct value at the time the doctests are being executed.Any other hints on how I can debug this in
numpy?Also, did you start seeing this behavior after upgrading pytest? If so, from which version did you upgrade?
soupault commentedon May 1, 2019
@nicoddemus Great analysis, thank you very much! At this point it rather looks like a numpy [past?] issue. I now have an idea that it might be related to the way numpy prints the arrays of platform-dependent types 🤔. Let me investigate this a bit further.
That is really smart! Silly me... 🤦♂
The AppVeyor configuration file is really old, so it is hard to say if the version of pytest makes any difference. I can check with several past versions and report to you back.
nicoddemus commentedon May 1, 2019
Sounds good, thanks!
soupault commentedon May 4, 2019
@nicoddemus It appears that the issue is, indeed, in the
numpyprint formatting - numpy/numpy#13468. I don't see how it can be related topytestanymore :).An interesting case, nevertheless.
Thank you very much for your analysis and support, and I'm really sorry for taking your time!
nicoddemus commentedon May 5, 2019
Not at all, glad I could help! Cheers!