Skip to content

Allow for v2.0.x series compatibility with pytest-astropy - #6833

Closed
drdavella wants to merge 13 commits into
astropy:v2.0.xfrom
drdavella:pytest-plugin-backport
Closed

drdavella wants to merge 13 commits into
astropy:v2.0.xfrom
drdavella:pytest-plugin-backport

Conversation

@drdavella

Copy link
Copy Markdown
Contributor

This also required a backport of the separation of Astropy's pytest plugins into individual modules.

@astropy-bot

astropy-bot Bot commented Nov 10, 2017 •

Copy link
Copy Markdown

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 😃.

I noticed the following issue with this pull request:

  • Changelog entry not present (or pull request number missing) and neither the Affects-dev nor the no-changelog-entry-needed label are set

Would it be possible to fix this? Thanks!

If there are any issues with this message, please report them here.

Comment thread astropy/tests/pytest_plugins.py Outdated
import pytest_doctestplus
del pytest_doctestplus
except ImportError:
pytest_plugins.append('astropy.tests.pytest_doctestplus')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that allows for compatibility with pytest-astropy begins here.

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For stuff that requires backport, I'll defer to @bsipocz . Thanks for the quick solution!

@pllim

pllim commented Nov 10, 2017

Copy link
Copy Markdown
Member

Hmm, technically, you have a change log, so you shouldn't label it as "no change log required".

@drdavella

Copy link
Copy Markdown
Contributor Author

@pllim that's true... technically the change log entry comes from a commit on v3.0, but I can just update the PR number for this commit.

On the other hand, I'm not sure that change required a change log entry to begin with...

But I'll leave the decision to someone else 🤐

@bsipocz

bsipocz commented Nov 10, 2017

Copy link
Copy Markdown
Member

Thanks @drdavella. I'll try to come back to this in a reasonable time, but probably only after I'm back from dotastro.

@drdavella
drdavella force-pushed the pytest-plugin-backport branch from 98bde63 to 561155e Compare November 10, 2017 19:01
@drdavella

Copy link
Copy Markdown
Contributor Author

@bsipocz thanks. There's something weird going on here, so it's going to take me a bit more time to sort it out anyway.

@drdavella
drdavella force-pushed the pytest-plugin-backport branch 4 times, most recently from 55b4106 to 3624fda Compare November 13, 2017 20:31
@drdavella
drdavella force-pushed the pytest-plugin-backport branch from 3624fda to 428fb92 Compare November 29, 2017 17:15
@eteq

eteq commented Nov 29, 2017

Copy link
Copy Markdown
Member

A quick note regarding some issues that have cropped up: when trying to use this to use the pytest plugins along side astropy, some issues appeared for me. Specifically, I get errors like those below when doing <someaffiliatedpackage>.test(). More debugging info in the Slack channel, but this should probably be resolved to make sure the new plugins don't kill affiliated packages' tests.

>>> photutils.test()
...
ValueError: option names {'--config-dir'} already added

This is to enable backwards compatibility with affiliated packages that
may both use the astropy test runner and import from
astropy.tests.pytest_plugins. In this case it prevents the config/cache
plugins from being registered with pytest more than once.
@drdavella
drdavella force-pushed the pytest-plugin-backport branch from c4f63cd to 4634fb2 Compare November 30, 2017 03:03
@drdavella

Copy link
Copy Markdown
Contributor Author

@eteq thanks for the report. This issue should be addressed in the latest commit.

@drdavella

Copy link
Copy Markdown
Contributor Author

@bsipocz, @astrofrog, I believe the travis failures for Py27 are unrelated to this PR. The failure on CircleCI appears to be related to the use of pytest-xdist, but I'm not sure whether that's a cause for concern or not.

@eteq

eteq commented Nov 30, 2017

Copy link
Copy Markdown
Member

I've checked and this latest commit fixes the problem with the affiliated package test(), so that's great!

@drdavella

Copy link
Copy Markdown
Contributor Author

@bsipocz, @eteq, @astrofrog, this is possibly a stupid question but how would we feel about making pytest-astropy a requirement for v2.0.3+? I've done most of the work already but i keep encountering strange issues in the attempt to backport compatibility. Rather than trying to support both cases, requiring pytest-astropy seems like it might be an easier solution. We could support this without API changes for affiliated packages, but they would have to install pytest-astropy if they use the test runner. The easiest thing to do for the v2.0.x series might be just to add pytest-astropy to install_requires for Astropy.

@eteq

eteq commented Nov 30, 2017 •

Copy link
Copy Markdown
Member

@drdavella - I'm 👎 on that because it goes against our general philosophy of no "big changes" (even if they're aren't features per se) in bugfix releases. Given the hiccups I've been encountering when going beyond the simplest cases, I think it's important we leave users/affiliated developers the option to leave things as they stand (at least until 4.0 when we stop supporting 2.x).

At some point it might be so big a maintenance burden that it's just not worth it, but it seems early to me to say that now. (Admittedly easy for me to say as I'm not the one doing most of it...)

But others might have a different opinion here.

@eteq eteq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor comment re: the changelog, but another thought related to the discussion above: it might be easier to maintain this if we change this to instead place all the new plugins into extern for astropy 2.0.x and control the plugin-loading on the pytest side instead of having to use astropy/tests/pytest_plugins.py to manage the loading. That will make future maintainence easier and might get around all the "two things are installed simultaneously" issues.

Comment thread CHANGES.rst

- Fixed a bug that meant that the data.astropy.org mirror could not be used when
using --remote-data=astropy. [#6724]
- Split pytest plugins into separate modules. [#6384]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be [#6384, #6833], right? I'm thinking that'll be useful for someone who sees this and wants to know where to find more context, and this is where the "real" merge happened for this version...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds sensible to me, too, though we should add the "manual backport" to #6384, too.

@bsipocz bsipocz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I only have a few marginal nitpicks.

Comment thread .travis.yml
env: SETUP_CMD='test --coverage --remote-data=astropy -a "--mpl"'
CONDA_DEPENDENCIES=$CONDA_ALL_DEPENDENCIES
PIP_DEPENDENCIES='cpp-coveralls objgraph jplephem pytest-mpl bintrees'
PIP_DEPENDENCIES='cpp-coveralls objgraph jplephem pytest-astropy pytest-mpl bintrees'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest-mpl is already part of pytest-astropy isn't it?

Comment thread CHANGES.rst

- Fixed a bug that meant that the data.astropy.org mirror could not be used when
using --remote-data=astropy. [#6724]
- Split pytest plugins into separate modules. [#6384]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, but add an empty line before this entry

Comment thread astropy/tests/__init__.py
"""

# NOTE: This is retained only for backwards compatibility. Affiliated packages
# should no longer import `disable_internet` from `astropy.tests`. It is now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick as it doesn't matter here, but better to pick up the habit to use double backticks for things not sphinx linkable

Comment thread astropy/tests/__init__.py
# command line flag. This is either passed to `pytest` directly or to the
# `setup.py test` command.
#
# TODO: This import should eventually be removed once backwards compatibility

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an eta for that? If we have please include, it's much easier to grep for it.

FIX)

class DocTestModulePlus(doctest_plugin.DoctestModule):
# pytest 2.4.0 defines "collect". Prior to that, it defined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this collect() below then just needed as a workaround for pytest <2.4? We already require 2.8 to the 2.0.x branch, so if yes, please remove.

from pkgutil import find_loader
# This is necessary to prevent pytest from reading the doctestplus plugin when
# the pytest_doctestplus standalone package is installed
if find_loader('pytest_doctestplus') is None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already been done in the test runner, is it necessary to repeat here, too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if yes, why not do it for remote-data and open files, too?

Comment thread astropy/tests/runner.py
"""
remote_data : {'none', 'astropy', 'any'}, optional
Controls whether to run tests marked with @remote_data. This can be
Controls whether to run tests marked with @pytest.mark.remote_data. This can be

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, now both @remote_data and pytest.mark.remote_data would work? Since we don't yet rely on pytest-astropy here, probably better to leave this as is?

@bsipocz

bsipocz commented Nov 30, 2017

Copy link
Copy Markdown
Member

@bsipocz, @eteq, @astrofrog, this is possibly a stupid question but how would we feel about making pytest-astropy a requirement for v2.0.3+? I've done most of the work already but i keep encountering

No, we can't do that. I tend to be amongs the flexible ones, but 2.0.x is LTS, so while I may agree adding a new dependency to a normal bugfix, it's really a no for LTS and for a something that terribly break backwards compatibility for the affiliates and such.

@bsipocz

bsipocz commented Nov 30, 2017

Copy link
Copy Markdown
Member

having the plugins in extern looks to be a good compromise to me, too if @drdavella agrees that it helps.

@drdavella

Copy link
Copy Markdown
Contributor Author

@bsipocz @eteq i'm working on a parallel PR now 🤞

@bsipocz

bsipocz commented Dec 5, 2017

Copy link
Copy Markdown
Member

Closing this as #6918 superseded it.

@bsipocz bsipocz closed this Dec 5, 2017
@drdavella
drdavella deleted the pytest-plugin-backport branch December 5, 2017 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants