Skip to content

Commit 6af0efc

Browse files
committed
Deprecate in testing.decorators
1 parent 6b2d3f2 commit 6af0efc

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Deprecations in ``testing.decorators``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The unused class ``CleanupTestCase`` and decorator ``cleanup`` are deprecated
5+
and will be removed. Vendor the code, including the private function
6+
``_cleanup_cm``.
7+
8+
The function ``check_freetype_version`` is considered internal and deprecated.
9+
Vendor the code of the private function ``_check_freetype_version``.

lib/matplotlib/testing/decorators.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
import matplotlib.style
1515
import matplotlib.units
1616
import matplotlib.testing
17-
from matplotlib import cbook, ft2font, pyplot as plt, ticker, _pylab_helpers
17+
from matplotlib import (_api, _pylab_helpers, cbook, ft2font, pyplot as plt,
18+
ticker)
1819
from .compare import comparable_formats, compare_images, make_test_filename
1920
from .exceptions import ImageComparisonFailure
2021

@@ -31,6 +32,8 @@ def _cleanup_cm():
3132
plt.close("all")
3233

3334

35+
@_api.deprecated("3.6", alternative="Vendor the existing code, "
36+
"including the private function _cleanup_cm.")
3437
class CleanupTestCase(unittest.TestCase):
3538
"""A wrapper for unittest.TestCase that includes cleanup operations."""
3639
@classmethod
@@ -42,6 +45,8 @@ def tearDownClass(cls):
4245
cls._cm.__exit__(None, None, None)
4346

4447

48+
@_api.deprecated("3.6", alternative="Vendor the existing code, "
49+
"including the private function _cleanup_cm.")
4550
def cleanup(style=None):
4651
"""
4752
A decorator to ensure that any global state is reset before
@@ -83,7 +88,13 @@ def wrapped_callable(*args, **kwargs):
8388
return make_cleanup
8489

8590

91+
@_api.deprecated("3.6", alternative="Vendor the existing code "
92+
"of _check_freetype_version.")
8693
def check_freetype_version(ver):
94+
return _check_freetype_version(ver)
95+
96+
97+
def _check_freetype_version(ver):
8798
if ver is None:
8899
return True
89100

@@ -98,7 +109,7 @@ def check_freetype_version(ver):
98109
def _checked_on_freetype_version(required_freetype_version):
99110
import pytest
100111
return pytest.mark.xfail(
101-
not check_freetype_version(required_freetype_version),
112+
not _check_freetype_version(required_freetype_version),
102113
reason=f"Mismatched version of freetype. "
103114
f"Test requires '{required_freetype_version}', "
104115
f"you have '{ft2font.__freetype_version__}'",

0 commit comments

Comments
 (0)