Repository navigation
Stop using bundled pytest version - #5694
Conversation
|
@astrofrog - Will astropy formally add pytest to the requirements? @larrybradley raised this in |
|
@bsipocz - if we do do this (and we've by no means made that decision) then we'll add py.test as a formal requirement to run the test suite (not to just use astropy) |
|
I opened a PR against this PR at astrofrog#63 for some stuff that might be useful but did not make it into #5688, as a reminder if nothing else. FYI. |
|
Without extra hacks (e.g. using ASTROPY_USE_SYSTEM_PYTEST or similar), it seems that before this makes it into release, affiliates are stuck with the bundled version, as it is already imported to the pytest namespace by the time the tests get to the point of importing the system pytest. e.g. here astropy/photutils#491 |
e4dcacd to
beae79f
Compare
|
@astrofrog - I did change |
|
@mhvk - indeed, the bundled version is 2.8 and on Python 3.3, pytest 2.7 is installed, so I guess our infrastructure only works for 2.8+. I'll make sure to mention that in the requirements now for testing when updating the docs. |
| - source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh | ||
|
|
||
| # Workaround for Python 3.3, for which pytest 2.8 or greater is not available | ||
| - if [[ $PYTHON_VERSION == 3.3 ]] then; |
There was a problem hiding this comment.
Ugh, I always get that wrong. Thanks!
1e2cb84 to
131258d
Compare
|
So one option here is to actually still remove the bundled pytest and just import the built-in one into astropy.tests.helper - that way the import will still work, but affiliated packages will still need to make sure that their tests pass with pytest 3.x. However since all the plugins have been fixed here, there might not actually be anything to fix in affiliated packages. For now, I've done this here so that we can test different affiliated packages with this branch. In addition, I've removed the workaround from #811 to check whether the bug has been fixed. |
|
Looks like the problem reported in #811 for which we had a workaround has been fixed for a couple of years (pytest-dev/pytest#112), so I think it's safe to remove the workaround. |
6d91cd3 to
cbdd7c4
Compare
|
This is ready for feedback! |
| from ...extern.six import next | ||
| from ...extern.six.moves import range | ||
|
|
||
| import pytest |
There was a problem hiding this comment.
move this up to the standard library imports (nit picking but I couldn't resist as you had this fixed everywhere else)
|
LGTM, thanks @astrofrog! |
pllim
left a comment
There was a problem hiding this comment.
Just a small comment about six import but I see that its import locations are mixed up everywhere anyway. I guess we can worry about it in 3 years when we stop Python 2 support. Nothing some grep and sed can't fix.
I really appreciate all the other import clean-ups!
Before merge, someone needs to carefully inspect all the PR test logs to make sure tests are running as expected (no missing doctest, etc) using the appropriate versions (no sneaky pytest 2.7). Also make sure any remaining warnings are expected.
| from .. import Constant | ||
| from ...units import Quantity as Q | ||
| from ...tests.helper import pytest | ||
| from ...extern import six |
There was a problem hiding this comment.
This change is unrelated to pytest. Also personally, I prefer to group six with __future__ for easy removal when we stop Python 2 support, as they both are for the same purpose.
2676332 to
a02992b
Compare
|
I've rebased this - @bsipocz would you be happy to review this? (to make sure I didn't mess anything up during rebase) |
|
As discussed with @eteq and @Cadair, we should add pytest as a runtime dependency for Astropy 2.0 to make things completely backward compatible. This actually makes sense anyway since Astropy provides pytest plugins which do have a dependency on pytest. In future (e.g. Astropy 3.0) we could then consider removing pytest from the dependencies but as @Cadair pointed out, we could even keep it indefinitely. In any case, once this is merged we should send an email to astropy-dev to explain this change. |
|
To add just a bit more to #5694 (comment), the argument for keeping it as a runtime dependency is primarily that we are providing plugins for pytest, so we should consider it a dependency. Although maybe we should call it an "optional dependency"? (Doesn't hold this up, just recording some of the discussion) |
eteq
left a comment
There was a problem hiding this comment.
One minor change suggested, but otherwise looks good (with the discussion referenced above in mind)
|
|
||
| setup_requires = ['numpy>=' + astropy.__minimum_numpy_version__] | ||
| install_requires = ['numpy>=' + astropy.__minimum_numpy_version__] | ||
| install_requires = ['pytest', 'numpy>=' + astropy.__minimum_numpy_version__] |
There was a problem hiding this comment.
Should this be pytest>2.8 instead of just pytest? The minversion in setup.cfg I think is not known by setup.py so e.g. a pip install won't update it as needed.
18cb93a to
e68015d
Compare
|
Who wants to have the honours to push the green button? @astrofrog? |
|
I think for big PRs it's best if it's not the author that merges, so feel free to do it :) |
|
🎉 Big thanks to @astrofrog to make this happen. |
|
I wonder whether this will need a what's new entry? |
This is equivalent to things like "dropping package x.x support", right? IMHO, if we don't put those in "what's new", I don't think it is needed here. |
|
Well, I would argue that this is very much different. While it doesn't have any effect on the simple user, it may have huge impact on packages that use the previously recommended way of using the bundled version directly from astropy, so it's more like a significant API change than just dropping a version support for something ancient. What I couldn't decide who the target audience for the "what's new". I expect maintainers to look at the full changelog and astropy-dev lists rather than the "what's new", but is that a good enough assumption? |
|
putting something like "astropy now depends on external pytest, this will be installed by default" shouldn't confuse the less technical users. |
|
But that wouldn't ring a bell for me as a maintainer either :) Anyway, as I said having just the changelog and the astropy-dev e-mail is probably enough. |
|
Maintainers like @olebole already unbundled pytest (in fact, one of the reasons we knew the version we used was getting rather old...). But perhaps he can still comment on what he would generally look at. |
|
I would recommend to have a statement like the one suggested by @Cadair here -- for a new version I usually check the Changelog for things like this when creating a Debian release. |
Bundled pytest was removed in v2.0 (astropy#5694) so it must now be imported directly.
As described in #5509, we should probably remove the bundled version of pytest. If we decide to do this, this PR is a WIP to do it.
This replaces the pytest in astropy.tests.helper by the standalone one to make sure the import still works. I've tested a couple of affiliated packages and they work fine with this, i.e. the pytest 3.x issues we had in the core were due to the custom plugins, but most affiliated packages don't have that issue. So I don't think we need to keep the bundled version temporarily or anything, I think it might just be fine this way. However, it would help if different affiliated package maintainers could verify this.
Adding a deprecation warning for the pytest import from astropy.tests.helper isn't easy to do, but I'm not convinced it's really needed since we need to import pytest in astropy.tests.helper anyway, so we won't be removing that import.
Things that still need to be done:
EDIT: Also see #5678, #5697
Edit: close #5974