New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for '_pytest' in sys.modules before trying to import Astropy's pytest #454
Conversation
Hmm... I think this makes sense, but I admit the pytest import structure has gotten me very confused at times. @iguananaut - you might add a note in the docs that indicates that either the @jiffyclub, since you're the original test master, does this seem reasonable to you? |
It seems reasonable to me that if the user is somehow manually invoking py.test on their own that we should try to use whatever installation they invoked. I was initially a little worried that this would end up with people trying to run the tests with versions of py.test that are too old, but the minimum version specified in the setup.cfg file should still catch those. |
Yeah, the py.test command is only installed if one has py.test itself installed. If one is just relying on what's included in Astropy there is no py.test. So using the py.test command line script sort of implies that you actually want to use whatever version of py.test that was installed with (which may not work with the Astropy tests--a disclaimer that we already make). |
This seems fine to me. |
@iguananaut - can you update |
Will do. |
Oh, and @iguananaut , feel free to merge once you've done that - this is pretty straightforward, after all. |
…e, it's likely that we're already running the py.test command, and so we should use the already imported system pytest.
Just to note, running py.test still doesn't work for me very well. Lots of tests fail--in particular all the wcs tests fail. Not sure what that's all about. I don't even get a traceback like this since I'm using the latest pytest. But I guess that's a separate issue. |
Actually looks like testguide.rst already states that running py.test uses the system version. So I think the docs were right, but the behavior was wrong. I'm just going to add a note in the changelog. |
Are the wcs tests failing because you're running from the source tree and not the installed (built) code? |
I dunno, probably. I only ever use |
I just tested this now, and it looks like the tests that don't require building are all working fine, and the @iguananaut - if you want you could add a brief note in the docs indicating that invoking via |
Actually the wcs tests work for me now with |
Check for '_pytest' in sys.modules before trying to import Astropy's pytest
Check for '_pytest' in sys.modules before trying to import Astropy's pytest
Because if '_pytest' is already in sys.modules it's likely that we're already running the py.test command, and so we should use the already imported system pytest.
This came up because when running the system py.test, if it's an older version than the one we're using now strange errors can occur such as:
This made even me a little frightened. If you set the
ASTROPY_USE_SYSTEM_PYTEST
environment variable everything works fine, but it's easy to miss that in the docs. I think this pull request makes a reasonable assumption...though I know this has been hashed out at length before, so maybe there's already a known good reason not to do this?