-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
update testing helpers #16990
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
update testing helpers #16990
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1168,29 +1168,29 @@ def _init_tests(): | |
"Freetype build type is {}local".format( | ||
"" if ft2font.__freetype_build_type__ == 'local' else "not ")) | ||
|
||
try: | ||
import pytest | ||
except ImportError: | ||
print("matplotlib.test requires pytest to run.") | ||
raise | ||
|
||
|
||
@cbook._delete_parameter("3.2", "switch_backend_warn") | ||
@cbook._delete_parameter("3.3", "recursionlimit") | ||
def test(verbosity=None, coverage=False, switch_backend_warn=True, | ||
recursionlimit=0, **kwargs): | ||
"""Run the matplotlib test suite.""" | ||
_init_tests() | ||
|
||
try: | ||
import pytest | ||
except ImportError: | ||
print("matplotlib.test requires pytest to run.") | ||
return -1 | ||
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 am skeptical about the API change, but this function is already returning an error code so any users of this will likely already be expecting to handle error codes so I expect it will do little harm. 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. That was basically my position. It wasn't obvious to me why this was "broken" and I thought it wasn't used anymore. It was, but I didn't have the right environment. I then sought to clarify the whole process until getting pytest to run. I was contemplating keeping the same API for this part, but the code would be less clear and as you noted the |
||
|
||
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')): | ||
raise ImportError("Matplotlib test data is not installed") | ||
print("Matplotlib test data is not installed") | ||
return -1 | ||
|
||
old_backend = get_backend() | ||
old_recursionlimit = sys.getrecursionlimit() | ||
try: | ||
use('agg') | ||
if recursionlimit: | ||
sys.setrecursionlimit(recursionlimit) | ||
import pytest | ||
|
||
args = kwargs.pop('argv', []) | ||
provide_default_modules = 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.
But now you don't make the warning about FreeType. Why did the
pytest
import check have to move into this function and not just stay in_init_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.
You do still get the import warning about FreeType because the pytest configure calls
_init_tests
matplotlib/lib/matplotlib/testing/conftest.py
Line 25 in 348e9fe
As originally written the
_init_tests
will be called twice: Once before the logger is set up (here), and then again by pytest (linked above) which by then logging is being captured. I didn't believe_init_tests
needed to be called here because it doesn't raise an exception and you're not going to see the logs since they aren't set up at this point. If the warning in_init_tests
isn't actually a warning it should be emitted in a way that a user can see it (currently it isn't).The reason I moved the
pytest
import into this function is so this function doesn't need to blindly captureImportError
and canreturn -1
forpytest
not being installed. This is all detailed in the PR description if you would like to read that.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.
@QuLogic thoughts?
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.
@QuLogic Does this satisfy your question? I've put this on the call agenda for tomorrow, but if you're ok with this, we don't have to spend time on it.