Skip to content

Avoid triggering deprecation warnings with pytest 3.8. #12154

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

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 18, 2018

The new API was introduced in pytest3.6 so bump the test dependency
accordingly.

xref https://docs.pytest.org/en/latest/changelog.html#pytest-3-6-0-2018-05-23
closes #12107.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

The new API was introduced in pytest3.6 so bump the test dependency
accordingly.
@tacaswell tacaswell added this to the v3.1 milestone Sep 19, 2018
@QuLogic QuLogic merged commit ca444e2 into matplotlib:master Sep 19, 2018
@anntzer anntzer deleted the pytest38 branch September 19, 2018 08:43
@QuLogic
Copy link
Member

QuLogic commented Sep 29, 2018

Trying to figure out why Pytest is crashing on Travis on the other branches, and I'm wondering if it's because there are too many warnings. I'm not sure if we should backport this as it bumps the pytest requirement (won't be a problem in Fedora at least)?

@ArchangeGabriel
Copy link
Contributor

Should this be backported to the 2.2.x branch?

@tacaswell
Copy link
Member

Lets see if it backports cleanly

@meeseeksdev backport to 2.2.x

@ArchangeGabriel if that does not go cleanly, are you interested in doing the backport? Failing that, we should just pin/document that you must use old versions of pytest with the 2.2.x branch.

@lumberbot-app
Copy link

lumberbot-app bot commented Jan 14, 2019

Something went wrong ... Please have a look at my logs.

It seem that the branch you are trying to backport to does not exists.

@tacaswell
Copy link
Member

@meeseeksdev backport to v2.2.x

sigh, second times the charm?

@lumberbot-app
Copy link

lumberbot-app bot commented Jan 14, 2019

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 v2.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 ca444e2a74759e559198403dbb1b96ff61489e79
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #12154: Avoid triggering deprecation warnings with pytest 3.8.'
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-12154-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR #12154 on branch v2.2.x"

And apply the correct labels and milestones.

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

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

@ArchangeGabriel
Copy link
Contributor

I’ve backported cleanly.

@ArchangeGabriel
Copy link
Contributor

The only difference is that with _cleanup_cm(): is not present in 2.2.x, so there is one level indentation difference.

The relevant part:

diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py
index 40ce56c4895..d2f699c2be8 100644
--- a/lib/matplotlib/testing/conftest.py
+++ b/lib/matplotlib/testing/conftest.py
@@ -24,19 +24,19 @@ def mpl_test_settings(request):
     original_settings = matplotlib.rcParams.copy()

     backend = None
-    backend_marker = request.keywords.get('backend')
+    backend_marker = request.node.get_closest_marker('backend')
     if backend_marker is not None:
         assert len(backend_marker.args) == 1, \
             "Marker 'backend' must specify 1 backend."
-        backend = backend_marker.args[0]
+        backend, = backend_marker.args
         prev_backend = matplotlib.get_backend()

     style = '_classic_test'  # Default of cleanup and image_comparison too.
-    style_marker = request.keywords.get('style')
+    style_marker = request.node.get_closest_marker('style')
     if style_marker is not None:
         assert len(style_marker.args) == 1, \
             "Marker 'style' must specify 1 style."
-        style = style_marker.args[0]
+        style, = style_marker.args

     matplotlib.testing.setup()
     if backend is not None:
@@ -64,7 +64,7 @@ def mpl_image_comparison_parameters(request, extension):
     # pytest won't get confused.
     # We annotate the decorated function with any parameters captured by this
     # fixture so that they can be used by the wrapper in image_comparison.
-    baseline_images = request.keywords['baseline_images'].args[0]
+    baseline_images, = request.node.get_closest_marker('baseline_images').args
     if baseline_images is None:
         # Allow baseline image list to be produced on the fly based on current
         # parametrization.

This fixed ~2500 errors in our build (ArchLinux). I can make a PR.

@tacaswell
Copy link
Member

Please do!

@ArchangeGabriel
Copy link
Contributor

Should I revert d7e3789 in the same PR or in a follow-up one?

@ArchangeGabriel
Copy link
Contributor

I will go with a follow-up one. Just a small note, seems https://github.com/matplotlib/matplotlib/blob/master/.appveyor.yml was not updated during this PR and still lists 3.4 as the minimum version instead of 3.6 everywhere else.

@ArchangeGabriel
Copy link
Contributor

#13181

QuLogic added a commit that referenced this pull request Jan 22, 2019
…154-on-v2.2.x

Backport PRs #12154, #12294, #12297, #12316, #13159 & #13205 to fix multiple tests issues
@QuLogic QuLogic modified the milestones: v3.1, v2.2.4 Jan 22, 2019
@ArchangeGabriel
Copy link
Contributor

Just a small note that part of my backporting work in #13181 should have been applied to 3.0.x too, and especially this PR. When building 3.0.3 for Arch, I’ve encountered numerous errors in tests that have been fixed in 2.2.4 but not 3.0.3. But since 3.0.3 was the last bugfix release, I suppose it is not worth backporting now?

@tacaswell
Copy link
Member

Drat, sorry we missed that 😞

3.0.3 is planned to be the last 3.0.x release and I am not sure doing a 3.0.4 to fix future compatibility with pytest is worth it, but if we find anything else we should fix this along with it.

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.

warnings re: deprecated pytest API with pytest 3.8
4 participants