Repository navigation
Relocate generic pytest plugins to separate repositories - #6606
Conversation
|
Hi there @drdavella 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here. |
|
I'll admit I'm not exactly sure how to install these plugins from git for the circleci build... |
| [#6449] | ||
| - Fixed issue with running test suite directly from ``pytest``. [#6437] | ||
|
|
||
| astropy.time |
There was a problem hiding this comment.
I'll do a thorough review later. At a glance, the inclusion of extra astropy.time section seems unrelated.
There was a problem hiding this comment.
Oh yeah, that was definitely an oversight. It might have happened when I rebased the old PR on the latest master (using git-rerere!!!).
There was a problem hiding this comment.
Off topic: Someone needs to implement git-argharghargh to undo rerere.
|
@drdavella - add pip install commands inside |
| - CONDA_DEPENDENCIES='Cython jinja2' | ||
| - CONDA_ALL_DEPENDENCIES='Cython jinja2 scipy h5py matplotlib pyyaml scikit-image pandas pytz beautifulsoup4 ipython mpmath bleach' | ||
| - PIP_DEPENDENCIES='' | ||
| # For testing purposes, before these packages are available on pypi |
There was a problem hiding this comment.
The changes to this file and to appveyor.yml are temporary and should NOT be merged. They are only necessary to support testing against the new plugin packages until they can be released on pypi.
|
I was getting failures from IERS locally and sort of assumed they weren't related. They're failing here now too, though. Does anyone know offhand whether this is a separate issue? |
|
There is an extra |
|
@pllim it's actually a very confusing error message: it's saying that the The |
| - CONDA_ALL_DEPENDENCIES='Cython jinja2 scipy h5py matplotlib pyyaml scikit-image pandas pytz beautifulsoup4 ipython mpmath bleach' | ||
| - PIP_DEPENDENCIES='' | ||
| # For testing purposes, before these packages are available on pypi | ||
| - GIT_DEPENDENCIES='git+https://github.com/astropy/pytest-doctestplus.git git+https://github.com/astropy/pytest-remotedata.git git+https://github.com/astropy/pytest-openfiles.git' |
There was a problem hiding this comment.
Does this even work? I never done it like this before. To install a package straight from repo, I use an incantation like https://github.com/spacetelescope/stsynphot_refactor/blob/master/.travis.yml#L103
There was a problem hiding this comment.
Well, the idea was that if GIT_DEPENDENCIES gets expanded within PIP_DEPENDENCIES properly, then pip knows what to do with those git+ ... strings. But it's apparently not working so I'll have to try something else.
|
@astrofrog, is git not installed in the docker image?
|
|
@drdavella - that's very possible. Just add an |
|
@astrofrog, I just realized that it was already in the script, but after my call to pip install. Sorry for the noise. |
| ] | ||
| # Pytest plugins | ||
| entry_points['pytest11'] = [ | ||
| # Don't collide with the 'doctestplus' plugin name that will be registered |
There was a problem hiding this comment.
This comment is no longer relevant.
| Time(Time.now().cxcsec, format='cxcsec', scale='ut1') | ||
| else: | ||
| Time(Time.now().cxcsec, format='cxcsec', scale='ut1') | ||
| Time(Time.now().cxcsec, format='cxcsec', scale='ut1') |
There was a problem hiding this comment.
Does this mean we should then add a second test with @internet_off? (once that exists)
There was a problem hiding this comment.
I think so; that's why I opened this issue astropy/pytest-remotedata#3. However, it's actually not clear to me how important it is to check for the exceptional condition here.
There was a problem hiding this comment.
Another consideration: would we then have to make sure to have at least one test run in the matrix with --remote-data=none?
|
Travis traceback: Appveyor traceback: CircleCI traceback: |
740e5f7 to
828edd7
Compare
|
Ideally I would like to test this using [edit] |
|
It might be worth releasing 'alpha' versions of the plugins before this PR is merged in any case to make sure this all works fine? |
828edd7 to
a99bfcc
Compare
Since these changes have the pleasant side effect of making native pytest runs possible, we want to make sure we actually test this functionality.
Since many affiliated packages may import global variables directly from the display plugin, we need to retain the original import location for backwards compatibility.
75af233 to
5912e3f
Compare
|
@astrofrog, @bsipocz I have tested these changes against |
@drdavella What did you do?! (If this involved code changes I would like to see it!) Am I right in thinking that the fact this PR is ready to go means all the external bits are in place, so I don't have to wait for this or astropy 3.0 to start porting SunPy to the external pytest plugins? |
bsipocz
left a comment
There was a problem hiding this comment.
Overall looks good. Most of my comments are nitpicks and not required for merging, but please do remove all six and python <3.5 related workarounds. (This module was deliberately left out of the big removal PRs).
| INSTALL_CMD='python setup.py build_ext --inplace' | ||
| TEST_CMD='pytest --open-files --doctest-rst' | ||
| script: | ||
| - echo "$INSTALL_CMD" |
There was a problem hiding this comment.
Why are these echos needed here? Travis lists these env variable at the top of the log file anyway, e.g. https://travis-ci.org/astropy/astropy/jobs/298131620#L498
There was a problem hiding this comment.
I'll remove these. There's also one at the bottom under script: which was not introduced by this PR.
There was a problem hiding this comment.
yes, please remove that one, too. If any more verbosity is needed, one can always use the DEBUG=True setting
| from astropy.tests.plugins.display import PYTEST_HEADER_MODULES | ||
| from astropy.tests.helper import enable_deprecations_as_exceptions | ||
|
|
||
| from .tests.pytest_plugins import * |
There was a problem hiding this comment.
this is great to see gone, probably we should also do it in the package-template to make it less black boxy
| """ | ||
|
|
||
| # NOTE: This is retained only for backwards compatibility. Affiliated packages | ||
| # should no longer import `disable_internet` from `astropy.tests`. It is now |
There was a problem hiding this comment.
It doesn't matter here as it's not processed by sphinx, but most of these backticks should be "``"
| cache_dir = item.config.getoption('cache_dir') or cache_dir | ||
|
|
||
| # We can't really use context managers directly in py.test (although | ||
| # py.test 2.7 adds the capability), so this may look a bit hacky |
There was a problem hiding this comment.
I'm not sure I got this perfectly. Why can't we use context managers? The pytest version requirement is already >=3.1
There was a problem hiding this comment.
The git blame shows that this comment is fairly old. I'm not sure whether this is worth fixing in this PR, but I'll take a look.
There was a problem hiding this comment.
sure, also, this one can be definitely left for a follow-up
| PYTEST_HEADER_MODULES = OrderedDict([('Numpy', 'numpy'), | ||
| ('Scipy', 'scipy'), | ||
| ('Matplotlib', 'matplotlib'), | ||
| ('h5py', 'h5py'), |
There was a problem hiding this comment.
please do move these to the astropy specific conftest.py, so neither h5py, nor pandas are inherited by affiliated packages. Actually maybe even scipy and mpl can be moved (see astropy/pyregion#120 (comment))
There was a problem hiding this comment.
I plan to open a separate issue/PR for this once this one is merged, if that's okay.
| except AttributeError: | ||
| stdoutencoding = 'ascii' | ||
|
|
||
| if six.PY2: |
There was a problem hiding this comment.
do we need this? astropy 3.0 won't even start up with python2
There was a problem hiding this comment.
Nope, it's just an oversight since this PR predates the Py3 migration.
| sys.getdefaultencoding(), | ||
| locale.getpreferredencoding(), | ||
| sys.getfilesystemencoding()) | ||
| if sys.version_info < (3, 3, 0): |
| s += "float info: dig: {0.dig}, mant_dig: {0.dig}\n\n".format( | ||
| sys.float_info) | ||
|
|
||
| for module_display, module_name in six.iteritems(PYTEST_HEADER_MODULES): |
| for op in special_opts: | ||
| op_value = getattr(config.option, op, None) | ||
| if op_value: | ||
| if isinstance(op_value, six.string_types): |
| testpaths = "astropy" "docs" | ||
| norecursedirs = "docs[\/]_build" "docs[\/]generated" "astropy[\/]extern" "astropy[\/]utils[\/]compat[\/]futures" | ||
| doctest_plus = enabled | ||
| doctest_norecursedirs = "LICENSE.rst" "CHANGES.rst" "examples" "astropy_helpers" |
There was a problem hiding this comment.
any reason not to put astropy_helpers to norecursedirs above? also why skip doctests for examples?
There was a problem hiding this comment.
It's not necessary to add astropy_helpers to norecursedirs since it's already excluded from testpaths. I don't think the examples directory contains any tests or docs to be tested, but maybe we can update that in another PR.
There was a problem hiding this comment.
Oh. But then would that be sensible for doctest to use the same configs? E.g. why does it run anything outside of testpaths?
There was a problem hiding this comment.
Anyway, it's totally fine again to leave it for a follow-up.
There was a problem hiding this comment.
I see what you're saying. I think it can safely be removed.
|
@Cadair I just ran the Since this PR provides backwards compatibility, the only thing that you will need to do once it is merged is |
|
@drdavella we don't actually use any of the astropy plugins at the moment (we didn't want all of them lol) so I need to pull them in where appropriate now they are separate. Thanks a lot for all your work on this! |
|
@Cadair even if |
|
Thanks @drdavella! |
|
Hey, only took 2.5 months with 95 comments. Not bad at all. |
Relocate generic pytest plugins to separate repositories
This builds on PR #6437, which can probably be closed now. It moves the pytest plugins into separate modules and loads them from
setup.pyrather than fromconftest.py. As a consequence, this allows tests to run directly frompytest, which has been broken for some time.This also removes
doctestplus,openfiles, andremotedatafrom the core repository and moves them into new standalone repositories (pytest-doctestplus, pytest-openfiles, and pytest-remotedata). These packages are not quite ready for release, but it is possible to test against them by installing from the development branches usingpip.Related issues: #6424, #5402, #6392, #6451