Skip to content

TST: pytest 7.0.0, scipy 1.8.0 broke a few things#12823

Merged
pllim merged 6 commits intoastropy:mainfrom
pllim:pytest-7-fires
Feb 14, 2022
Merged

TST: pytest 7.0.0, scipy 1.8.0 broke a few things#12823
pllim merged 6 commits intoastropy:mainfrom
pllim:pytest-7-fires

Conversation

@pllim
Copy link
Member

@pllim pllim commented Feb 4, 2022

Description

This pull request is to fix some stuff that pytest 7.0.0 release broke.

Need new asdf release:

Out of scope:

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the Extra CI label.
  • Is a change log needed? If yes, did the change log check pass? If no, add the no-changelog-entry-needed label. If this is a manual backport, use the skip-changelog-checks label unless special changelog handling is necessary.
  • Is a milestone set? Milestone must be set but astropy-bot check might be missing; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate backport-X.Y.x label(s) before merge.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2022

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@saimn
Copy link
Contributor

saimn commented Feb 4, 2022

Another issue is that pytest.warns(None) is deprecated, because "because many people used it to mean “this code does not emit warnings”, but it actually had the effect of checking that the code emits at least one warning of any type".

❯ rg "pytest.warns\(None\)" | wc -l
35

We should replace those with the solutions advised here: https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests

@pllim
Copy link
Member Author

pllim commented Feb 4, 2022

Thanks, @saimn ! I'll get to that later today.

@dhomeier
Copy link
Contributor

dhomeier commented Feb 4, 2022

We should replace those with the solutions advised here: https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests

For asdf @WilliamJamieson has fixed it in asdf-format/asdf#1075.

@dhomeier
Copy link
Contributor

dhomeier commented Feb 4, 2022

In addition there is an RTD warning/failure due to moved paths (along with the h5py one):

intersphinx inventory has moved: http://docs.h5py.org/en/stable/objects.inv -> https://docs.h5py.org/en/stable/objects.inv
intersphinx inventory has moved: https://pytest.readthedocs.io/en/stable/objects.inv -> https://docs.pytest.org/en/stable/objects.inv

header = hdul[1].header
with pytest.warns(None) as warning_list:
header["HIERARCH LONG KEYWORD"] = 42
assert len(warning_list) == 0
Copy link
Member Author

Choose a reason for hiding this comment

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

Unless this is emitting a warning that we are purposely ignoring in setup.cfg, we do not need a check.

Copy link
Contributor

@saimn saimn Feb 8, 2022

Choose a reason for hiding this comment

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

This probably comes from before the switch to use pytest's warning system. But given that the aim of this test is to test that no warning is emitted, it probably makes sense to check that explicitly ? Or at least add a comment explaining that if a warning is emitted this would fail the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I added them back.

intersphinx_mapping['sphinx_automodapi'] = ('https://sphinx-automodapi.readthedocs.io/en/stable/', None) # noqa: F405, E501
intersphinx_mapping['packagetemplate'] = ('https://docs.astropy.org/projects/package-template/en/latest/', None) # noqa: F405, E501
intersphinx_mapping['h5py'] = ('http://docs.h5py.org/en/stable/', None) # noqa: F405
intersphinx_mapping['h5py'] = ('https://docs.h5py.org/en/stable/', None) # noqa: F405
Copy link
Member Author

Choose a reason for hiding this comment

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

For the record, the URL in sphinx-astropy is already correct.

@pllim
Copy link
Member Author

pllim commented Feb 4, 2022

Hrrmmm... looks like pytest.warns() fails on zero warnings.

@pllim pllim force-pushed the pytest-7-fires branch 3 times, most recently from 4fc1b79 to 7259526 Compare February 4, 2022 23:22
@pllim pllim added the Extra CI Run cron CI as part of PR label Feb 5, 2022
@pllim

This comment was marked as resolved.

@pllim pllim force-pushed the pytest-7-fires branch 3 times, most recently from f57db5b to fc86e62 Compare February 5, 2022 04:02
setup.cfg Outdated
jplephem
mpmath
asdf>=2.6
asdf@git+https://github.com/asdf-format/asdf.git
Copy link
Member Author

@pllim pllim Feb 5, 2022

Choose a reason for hiding this comment

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

Tests are only passing with this pin, so that means we either have to:

  • Pin pytest<7

OR

  • Wait for asdf to release and then bump minversion of asdf to that release.

This pin broke RTD and linkcheck but that is okay because we will not merge with this pin anyway.

jplephem
mpmath
asdf>=2.6
asdf>=2.9.2
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this too controversial for backport, @nden , @WilliamJamieson , or @eslavich ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so, the worst thing someone would encounter upgrading from 2.6 --> 2.9.2 is a deprecation warning. We've been pretty good about staying true to semantic versioning.

This comment was marked as resolved.

@pllim pllim changed the title TST: pytest 7.0.0 broke a few things TST: pytest 7.0.0, scipy 1.8.0 broke a few things Feb 8, 2022
pllim added 6 commits February 8, 2022 17:17
and replace it with warnings.catch_warnings()
or pytest.warns(); the latter fails on zero warning.

Bump pytest minversion to 7 because pytest.warns() is new there.

Ignore pytest-asdf warning that is already fixed upstream.
cosmology/tests/test_funcs.py warnings changed.
@larrybradley
Copy link
Member

@pllim The changes in convolution LGTM. Thanks!

Copy link
Member

@nstarman nstarman left a comment

Choose a reason for hiding this comment

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

Cosmology section LGTM!

Copy link
Member

@adrn adrn left a comment

Choose a reason for hiding this comment

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

Coordinates change looks fine, if it works!

@pllim
Copy link
Member Author

pllim commented Feb 14, 2022

I see a few PR merges are getting held up by CI failures. So let's get this in. If the rest of the subpackage maintainers not happy with the diff, they can open follow-up PRs. Thanks!

@pllim pllim merged commit aecb0de into astropy:main Feb 14, 2022
@pllim pllim deleted the pytest-7-fires branch February 14, 2022 15:08
@lumberbot-app
Copy link

lumberbot-app bot commented Feb 14, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v5.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -m1 aecb0de64ea872952fa724061c4896e0df263529
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #12823: TST: pytest 7.0.0, scipy 1.8.0 broke a few things'
  1. Push to a named branch:
git push YOURFORK v5.0.x:auto-backport-of-pr-12823-on-v5.0.x
  1. Create a PR against branch v5.0.x, I would have named this PR:

"Backport PR #12823 on branch v5.0.x (TST: pytest 7.0.0, scipy 1.8.0 broke a few things)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@mhvk
Copy link
Contributor

mhvk commented Feb 14, 2022

@pllim - thanks so much for what turned out to be quite the task! (And all great for units)

pllim added a commit to pllim/astropy that referenced this pull request Feb 14, 2022
TST: pytest 7.0.0, scipy 1.8.0 broke a few things
pllim added a commit that referenced this pull request Feb 14, 2022
…5.0.x

Backport PR #12823 on branch v5.0.x (TST: pytest 7.0.0, scipy 1.8.0 broke a few things)
eerovaher added a commit to eerovaher/pytest-astropy that referenced this pull request Mar 3, 2022
Using older versions of `pytest` is not possible since
astropy/astropy#12823.
eerovaher added a commit to eerovaher/astropy that referenced this pull request Mar 3, 2022
Using older versions of `pytest` is not possible since
astropy#12823. Furthermore, `pytest-doctestplus` was made
compatible with `pytest` 7.0 in scientific-python/pytest-doctestplus#171, so its
minimum required version has to be updated too.
nstarman pushed a commit to nstarman/astropy that referenced this pull request Mar 9, 2022
Using older versions of `pytest` is not possible since
astropy#12823. Furthermore, `pytest-doctestplus` was made
compatible with `pytest` 7.0 in scientific-python/pytest-doctestplus#171, so its
minimum required version has to be updated too.
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.

8 participants