-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
TST: Prepare for pytest 9 #28195
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
TST: Prepare for pytest 9 #28195
Conversation
The current version of pytest is warning that using `importorskip` to catch `ImportError` will start being ignored (and thus raising) with pytest 9. Fortunately, in all cases, we don't need these calls, as they are: - already checked for `ImportError` at the top-level of the file - already checked by the backend switcher - not actually possible to fail importing
test_backend = pytest.importorskip( | ||
f'matplotlib.backends.backend_{backend}' | ||
) | ||
test_backend = importlib.import_module(f'matplotlib.backends.backend_{backend}') |
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.
backend
here is svg, ps, pdf, or pgf, which are not expected to fail (maybe they used to when Pillow was optional?)
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.
maybe crossed streams with the mark on the pgf parameter?
@@ -3,9 +3,6 @@ | ||
import pytest | ||
|
||
|
||
pytest.importorskip("matplotlib.backends.backend_gtk3agg") | ||
|
||
|
||
@pytest.mark.backend("gtk3agg", skip_on_importerror=True) |
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.
This is the only test, so the backend switch covers the import check.
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat') | ||
QtCore = qt_compat.QtCore | ||
|
||
from matplotlib.backends.qt_compat import QtCore |
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.
qt_compat
is checked above on line 18, and the whole module is skipped.
Doesn't that defeat the purpose of |
They plan to only catch |
Ah ha! I completely missed the addition of ModuleNotFound (which was in 3.6) so this makes sense. |
…195-on-v3.9.x Backport PR #28195 on branch v3.9.x (TST: Prepare for pytest 9)
PR summary
The current version of pytest is warning that using
importorskip
to catchImportError
will start being ignored (and thus raising) with pytest 9.Fortunately, in all cases, we don't need these calls, as they are:
ImportError
at the top-level of the filePR checklist