Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Convert test decorators to pytest fixtures#7973
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1476,7 +1476,6 @@ def _jupyter_nbextension_paths(): | ||
| default_test_modules = [ | ||
| 'matplotlib.tests.test_png', | ||
| 'matplotlib.tests.test_units', | ||
| ] | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. what's happening there? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. When switching to the automatic fixture and dropping any Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Sorry for being dense, but why does this variable even exist? Why do we have a default whitelist of tests? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's used for Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do weneed to keep MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yes, that's why I pass only the top-level modules; but we still need to pass something because this works on the installed version and we need to hit both Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't get it. After the general conversion, do we expect
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The answer to the first question is no as far as our own tests are concerned. But Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. So wealready broke backcompat on our tests by having a requirement on pytest, and by making it not possible to run the test suite by running MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Again, I'm not against it, but I think this discussion really belongs on#7974 where that code is actually changed. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from __future__ import (absolute_import, division, print_function, | ||
| unicode_literals) | ||
| from matplotlib.tests.conftest import mpl_test_settings |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from __future__ import (absolute_import, division, print_function, | ||
| unicode_literals) | ||
| import pytest | ||
| import matplotlib | ||
| @pytest.fixture(autouse=True) | ||
| def mpl_test_settings(request): | ||
| from matplotlib.testing.decorators import _do_cleanup | ||
| original_units_registry = matplotlib.units.registry.copy() | ||
| original_settings = matplotlib.rcParams.copy() | ||
| backend = None | ||
| backend_marker = request.keywords.get('backend') | ||
| if backend_marker is not None: | ||
| assert len(backend_marker.args) == 1, \ | ||
| "Marker 'backend' must specify 1 backend." | ||
| backend = backend_marker.args[0] | ||
| prev_backend = matplotlib.get_backend() | ||
| style = 'classic' | ||
| style_marker = request.keywords.get('style') | ||
| if style_marker is not None: | ||
| assert len(style_marker.args) == 1, \ | ||
| "Marker 'style' must specify 1 style." | ||
| style = style_marker.args[0] | ||
| matplotlib.testing.setup() | ||
| if backend is not None: | ||
| # This import must come after setup() so it doesn't load the default | ||
| # backend prematurely. | ||
| import matplotlib.pyplot as plt | ||
| plt.switch_backend(backend) | ||
| matplotlib.style.use(style) | ||
| try: | ||
| yield | ||
| finally: | ||
| if backend is not None: | ||
| import matplotlib.pyplot as plt | ||
| plt.switch_backend(prev_backend) | ||
| _do_cleanup(original_units_registry, | ||
| original_settings) |
Uh oh!
There was an error while loading.Please reload this page.