-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix testing for pytest 7.2 support
#13892
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
Conversation
pllim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something else needs updating to get past the CI failure of this PR.
Thanks for tackling this!
| """ | ||
|
|
||
| def setup(self): | ||
| def setup_method(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not setup_class? Does this need to be redefined before every method test?
Same question for all other similar changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://docs.pytest.org/en/7.2.x/deprecations.html#nose-deprecation setup_method teardown_method are the replacements for setup and teardown.
252e17a to
7a3cdf0
Compare
7a3cdf0 to
7ef2116
Compare
| # Clip the image to the frame | ||
| im.set_clip_path(ax.coords.frame.patch) | ||
|
|
||
| return fig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this isn't needed for them weird hash image comparison that CircleCI picks up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is intentional... #5496 cc @astrofrog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the pytest changelog:
#10196:` PytestReturnNotNoneWarning is now a subclass of PytestRemovedIn8Warning: the plan is to make returning non-None from tests an error in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like pytest isn't gonna back down, so we're blocked by matplotlib/pytest-mpl#183 . I see two immediate actions we can take:
- Pin maxversion of pytest to
<7.2to immediately unblock all the other PRs for feature freeze week. Turn this PR to draft until upstream can figure out the compatibility. - Continue with this PR but use
pytest.mark.filterwarningsto ignore this warning for the affected image tests. But this is also risky because if we forget and they turn warning into exception in a future release, we still have to pin maxversion then.
What to do?
a482a36 to
0ed693d
Compare
0ed693d to
4549377
Compare
pllim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff looks reasonable to me and skipping is fine, since we don't calculate coverage for remote data anyway. Thanks!
This comment was marked as resolved.
This comment was marked as resolved.
Fix testing for `pytest` 7.2 support
| style=style, | ||
| savefig_kwargs=savefig_kwargs, | ||
| **kwargs) | ||
| @pytest.mark.skipif(not HAS_PYTEST_MPL, reason='pytest-mpl is required for the figure tests') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about reverting this and use -m "not mpl_image_compare" as suggested in matplotlib/pytest-mpl#183 (comment) but I cannot figure out a sane way to define that in tox.ini because we have a few possible flag combos already and CircleCI can theoretically use any of those flags if it wants to.
Lines 119 to 124 in 7e80b9f
| commands = | |
| pip freeze | |
| !cov-!double: pytest --pyargs astropy {toxinidir}/docs {env:MPLFLAGS} {posargs} | |
| cov-!double: pytest --pyargs astropy {toxinidir}/docs {env:MPLFLAGS} --cov astropy --cov-config={toxinidir}/pyproject.toml {posargs} | |
| double: python -c 'import sys; from astropy import test; test(); sys.exit(test())' | |
| cov: coverage xml -o {toxinidir}/coverage.xml |
Maybe this is still the best option we have unless people have better ideas.
Description
pytest7.2 was just released. It deprecates several things thatastropywas using for testing, includingsetupandteardownfunctions. This PR fixes all those deprecations by switching them over tosetup_methodandteardown_method.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.
Extra CIlabel. Codestyle issues can be fixed by the bot.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.