Repository navigation
Astropy test customizations break pytest for affiliated packages #5402
Description
Activity
@josePhoenix - can you clarify why you need
py.testto work? That is, is there some specific reason whypython setup.py testis insufficient, or is it just that usingpy.testfeel more natural?- I can control the version of the
pytestexecutable - It is a documented way of running the astropy tests
- It is the format used in all the examples: http://docs.pytest.org/en/latest/usage.html
- Not every pytest option is available through Astropy's
setup.py test
For projects I'm part of that use more-or-less "vanilla" PyTest, the instructions are "cd projdir/; pytest". If questions come up, I can refer to http://docs.pytest.org/.
For affiliated packages, the instructions are "python setup.py test". That much is equivalently simple. But as soon as you need to go beyond that, all bets are off. The command line arguments are not documented anywhere beyond the level in the
python setup.py test --helpoutput. I opened an issue with astropy-helpers because I'm using the package template and the setup.py customizations live in the helpers, and I was told it's actually in astropy. I guess there's documentation in the astropy docs (partially reproducing the pytest documentation), but I have yet to meet a casual contributor that reads all the documentation of the project they're contributing to and all the documentation of its dependencies.But really, at the end of the day, I'm quite lazy and would simply rather type
pytest ./webbpsf/tests/test_errorhandling.pythan
ASTROPY_USE_SYSTEM_PYTEST=1 python setup.py test -t ./webbpsf/tests/test_errorhandling.pyto accomplish the same thing.
Reacted by Adam Ginsburg- I can control the version of the
@josePhoenix - I'm 100% with you that it should work - I was asking to see whether there's a particular use case missing from the existing machinery that you need it for. So I'm not arguing that you shouldn't be able to use
py.testhere, but just letting you know that two of these are supported by thepython setup.py testcase to let you work around it for now:- I can control the version of the pytest executable
You can use
ASTROPY_USE_SYSTEM_PYTEST=1for this if you want - then it will use whatever the system's default pytest is, which you can set to whichever one you want. Definitely not as easy as giving the executable directly, but it will work in a pinch.And note that if you want to force this for your package so that it never uses the bundled
py.test, you can set that to be the default in thesetup.cfg. That's the intended way to configure all of the test stuff (whichpytestinvocations should respect... but clearly the bug here is preventing that)- Not every pytest option is available through Astropy's setup.py test
They should be, using the
-a/--argspython setup.py testoptions. Anything provided there gets passed directly topy.test.would simply rather type
pytest ./webbpsf/tests/test_errorhandling.py
Just to be clear, this is subtly different from the
python setup.py testcase. The former runs the test in the source directory and the latter in the build directory. These are subtly different, and usually the latter is slightly safer. So it's not quite identical...All of that said, there is clearly a bug here that should be fixed! I just want to make it clear that the
python setup.py testmachinery is there for a reason, not just to make for longer command-line typing.@pllim @astrofrog @embray - do any of you understand why this is happening? It seems like some of the plugin machinery is not getting recognized and its hence failing due to a lack of the remote_data markings.
I'll try to dig into it when I get a chance if no one else has any ideas...
I can't comment much... Sorry.
Well, it's from this commit: https://github.com/astropy/astropy/pull/2044/files#diff-e602ffb35fbd67477e5543c9cc3846d4R132
And most likely because no default was specified (see http://docs.pytest.org/en/latest/writing_plugins.html?highlight=getoption#_pytest.config.Config.getoption ).
Reacted by Erik Tollerud👍 @josePhoenix , you are welcome to submit a fix to Astropy.
- added a commit that references this issue
on Oct 26, 2016 Is this still an issue? There are PRs to fix compatibility with pytest 3 and also to update the doc for testing.
Doc was updated and changes to deal with pytest 3.x were merged. Closing for now. Please re-open if you run into this again.
Moved from astropy/astropy-helpers#258
Every so often I make the mistake of running
pytest(orpy.testfor old versions) instead ofpython setup.py test. It seems like this should work, but instead I get errors collecting tests that seem to be related to the astropy helpers. Even though the file doesn't appear in the traceback below, it seems to come from imports in theconftest.pyfrom the package template.This also appears to bite unwary users of packages that use the template: http://stackoverflow.com/questions/31410723/error-using-pytest-tutorial
At @pllim's request, I tried the last 2.x release of pytest as well:
I also confirmed that removing the
conftest.pyI mentioned above resolves the issue, which implicates thefrom astropy.tests.pytest_plugins import *line. Hence the moved issue.