6
6
import shutil
7
7
import string
8
8
import sys
9
- import unittest
10
9
import warnings
11
10
12
11
from packaging .version import parse as parse_version
13
12
14
13
import matplotlib .style
15
14
import matplotlib .units
16
15
import matplotlib .testing
17
- from matplotlib import (_api , _pylab_helpers , cbook , ft2font , pyplot as plt ,
18
- ticker )
16
+ from matplotlib import _pylab_helpers , cbook , ft2font , pyplot as plt , ticker
19
17
from .compare import comparable_formats , compare_images , make_test_filename
20
18
from .exceptions import ImageComparisonFailure
21
19
@@ -32,68 +30,6 @@ def _cleanup_cm():
32
30
plt .close ("all" )
33
31
34
32
35
- @_api .deprecated ("3.6" , alternative = "a vendored copy of the existing code, "
36
- "including the private function _cleanup_cm" )
37
- class CleanupTestCase (unittest .TestCase ):
38
- """A wrapper for unittest.TestCase that includes cleanup operations."""
39
- @classmethod
40
- def setUpClass (cls ):
41
- cls ._cm = _cleanup_cm ().__enter__ ()
42
-
43
- @classmethod
44
- def tearDownClass (cls ):
45
- cls ._cm .__exit__ (None , None , None )
46
-
47
-
48
- @_api .deprecated ("3.6" , alternative = "a vendored copy of the existing code, "
49
- "including the private function _cleanup_cm" )
50
- def cleanup (style = None ):
51
- """
52
- A decorator to ensure that any global state is reset before
53
- running a test.
54
-
55
- Parameters
56
- ----------
57
- style : str, dict, or list, optional
58
- The style(s) to apply. Defaults to ``["classic",
59
- "_classic_test_patch"]``.
60
- """
61
-
62
- # If cleanup is used without arguments, *style* will be a callable, and we
63
- # pass it directly to the wrapper generator. If cleanup if called with an
64
- # argument, it is a string naming a style, and the function will be passed
65
- # as an argument to what we return. This is a confusing, but somewhat
66
- # standard, pattern for writing a decorator with optional arguments.
67
-
68
- def make_cleanup (func ):
69
- if inspect .isgeneratorfunction (func ):
70
- @functools .wraps (func )
71
- def wrapped_callable (* args , ** kwargs ):
72
- with _cleanup_cm (), matplotlib .style .context (style ):
73
- yield from func (* args , ** kwargs )
74
- else :
75
- @functools .wraps (func )
76
- def wrapped_callable (* args , ** kwargs ):
77
- with _cleanup_cm (), matplotlib .style .context (style ):
78
- func (* args , ** kwargs )
79
-
80
- return wrapped_callable
81
-
82
- if callable (style ):
83
- result = make_cleanup (style )
84
- # Default of mpl_test_settings fixture and image_comparison too.
85
- style = ["classic" , "_classic_test_patch" ]
86
- return result
87
- else :
88
- return make_cleanup
89
-
90
-
91
- @_api .deprecated ("3.6" , alternative = "a vendored copy of the existing code "
92
- "of _check_freetype_version" )
93
- def check_freetype_version (ver ):
94
- return _check_freetype_version (ver )
95
-
96
-
97
33
def _check_freetype_version (ver ):
98
34
if ver is None :
99
35
return True
0 commit comments