diff --git a/doc/api/api_changes_3.3/deprecations.rst b/doc/api/api_changes_3.3/deprecations.rst index 680f049249e3..f32aa8c0e312 100644 --- a/doc/api/api_changes_3.3/deprecations.rst +++ b/doc/api/api_changes_3.3/deprecations.rst @@ -423,6 +423,12 @@ or None is deprecated; set it to "horizontal" instead. Moreover, the two orientations ("horizontal" and "vertical") will become case-sensitive in the future. +`CleanupTestCase` and `cleanup` in decorators deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The class `matplotlib.testing.decorators.CleanupTestCase` and the decorator +`matplotlib.testing.decorators.cleanup` are not used in the code base. We have +an automatic cleanup via an auto-used fixture instead. + *minor* kwarg to `.Axis.get_ticklocs` will become keyword-only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Passing this argument positionally is deprecated. diff --git a/doc/badsectors.txt b/doc/badsectors.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index f1c988370c6e..cd68f837fc72 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -35,58 +35,6 @@ def _cleanup_cm(): plt.close("all") -class CleanupTestCase(unittest.TestCase): - """A wrapper for unittest.TestCase that includes cleanup operations.""" - @classmethod - def setUpClass(cls): - cls._cm = _cleanup_cm().__enter__() - - @classmethod - def tearDownClass(cls): - cls._cm.__exit__(None, None, None) - - -def cleanup(style=None): - """ - A decorator to ensure that any global state is reset before - running a test. - - Parameters - ---------- - style : str, dict, or list, optional - The style(s) to apply. Defaults to ``["classic", - "_classic_test_patch"]``. - """ - - # If cleanup is used without arguments, *style* will be a callable, and we - # pass it directly to the wrapper generator. If cleanup if called with an - # argument, it is a string naming a style, and the function will be passed - # as an argument to what we return. This is a confusing, but somewhat - # standard, pattern for writing a decorator with optional arguments. - - def make_cleanup(func): - if inspect.isgeneratorfunction(func): - @functools.wraps(func) - def wrapped_callable(*args, **kwargs): - with _cleanup_cm(), matplotlib.style.context(style): - yield from func(*args, **kwargs) - else: - @functools.wraps(func) - def wrapped_callable(*args, **kwargs): - with _cleanup_cm(), matplotlib.style.context(style): - func(*args, **kwargs) - - return wrapped_callable - - if callable(style): - result = make_cleanup(style) - # Default of mpl_test_settings fixture and image_comparison too. - style = ["classic", "_classic_test_patch"] - return result - else: - return make_cleanup - - def check_freetype_version(ver): if ver is None: return True