diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 7b8baf8aae3a..32e476cacc5a 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -24,7 +24,7 @@ import warnings import re -from matplotlib import cbook +from matplotlib import cbook, testing from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper from matplotlib.fontconfig_pattern import parse_fontconfig_pattern from matplotlib.colors import is_color_like @@ -266,19 +266,28 @@ def validate_backend(s): return _validate_standard_backends(s) -@deprecated("2.2", +def validate_qt4(s): + # Don't spam the test suite with warnings every time the rcparams are + # reset. While it may seem better to use filterwarnings from within the + # test suite, pytest 3.1+ explicitly disregards warnings filters (pytest + # issue #2430). + if not testing.is_called_from_pytest(): + cbook.warn_deprecated( + "2.2", "The backend.qt4 rcParam was deprecated in version 2.2. In order " "to force the use of a specific Qt4 binding, either import that " "binding first, or set the QT_API environment variable.") -def validate_qt4(s): return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s) -@deprecated("2.2", +def validate_qt5(s): + # See comment re: validate_qt4. + if not testing.is_called_from_pytest(): + cbook.warn_deprecated( + "2.2", "The backend.qt5 rcParam was deprecated in version 2.2. In order " "to force the use of a specific Qt5 binding, either import that " "binding first, or set the QT_API environment variable.") -def validate_qt5(s): return ValidateInStrings("backend.qt5", ['PyQt5', 'PySide2'])(s) diff --git a/lib/matplotlib/testing/__init__.py b/lib/matplotlib/testing/__init__.py index 36a7403698f2..2bd4425a2bac 100644 --- a/lib/matplotlib/testing/__init__.py +++ b/lib/matplotlib/testing/__init__.py @@ -4,8 +4,8 @@ import functools import warnings -import matplotlib -from matplotlib import cbook, rcParams, rcdefaults, use +import matplotlib as mpl +from matplotlib import cbook def _is_list_like(obj): @@ -15,7 +15,7 @@ def _is_list_like(obj): def is_called_from_pytest(): """Returns whether the call was done from pytest""" - return getattr(matplotlib, '_called_from_pytest', False) + return getattr(mpl, '_called_from_pytest', False) def _copy_metadata(src_func, tgt_func): @@ -26,13 +26,13 @@ def _copy_metadata(src_func, tgt_func): def set_font_settings_for_testing(): - rcParams['font.family'] = 'DejaVu Sans' - rcParams['text.hinting'] = False - rcParams['text.hinting_factor'] = 8 + mpl.rcParams['font.family'] = 'DejaVu Sans' + mpl.rcParams['text.hinting'] = False + mpl.rcParams['text.hinting_factor'] = 8 def set_reproducibility_for_testing(): - rcParams['svg.hashsalt'] = 'matplotlib' + mpl.rcParams['svg.hashsalt'] = 'matplotlib' def setup(): @@ -51,12 +51,12 @@ def setup(): "Could not set locale to English/United States. " "Some date-related tests may fail") - use('Agg', warn=False) # use Agg backend for these tests + mpl.use('Agg', warn=False) # use Agg backend for these tests # These settings *must* be hardcoded for running the comparison # tests and are not necessarily the default values as specified in # rcsetup.py - rcdefaults() # Start with all defaults + mpl.rcdefaults() # Start with all defaults set_font_settings_for_testing() set_reproducibility_for_testing()