5
5
6
6
import os
7
7
import sys
8
+ import warnings
8
9
9
10
import matplotlib as mpl
10
11
from matplotlib .tests import assert_str_equal
@@ -97,29 +98,31 @@ def test_RcParams_class():
97
98
98
99
def test_Bug_2543 ():
99
100
# Test that it possible to add all values to itself / deepcopy
100
- # This was not possible because validate_bool_maybe_none did not
101
+ # This was not possible because validate_bool_maybe_none did not
101
102
# accept None as an argument.
102
103
# https://github.com/matplotlib/matplotlib/issues/2543
103
- with mpl .rc_context ():
104
- _copy = mpl .rcParams .copy ()
105
- for key in six .iterkeys (_copy ):
106
- mpl .rcParams [key ] = _copy [key ]
107
- mpl .rcParams ['text.dvipnghack' ] = None
108
- with mpl .rc_context ():
109
- from copy import deepcopy
110
- _deep_copy = deepcopy (mpl .rcParams )
111
- from matplotlib .rcsetup import validate_bool_maybe_none , validate_bool
112
- # real test is that this does not raise
113
- assert_true (validate_bool_maybe_none (None ) is None )
114
- assert_true (validate_bool_maybe_none ("none" ) is None )
115
- _fonttype = mpl .rcParams ['svg.fonttype' ]
116
- assert_true (_fonttype == mpl .rcParams ['svg.embed_char_paths' ])
117
- with mpl .rc_context ():
118
- mpl .rcParams ['svg.embed_char_paths' ] = False
119
- assert_true (mpl .rcParams ['svg.fonttype' ] == "none" )
104
+ with warnings .catch_warnings ():
105
+ warnings .filterwarnings ('ignore' , message = '.*(deprecated|obsolete)' , category = UserWarning )
106
+ with mpl .rc_context ():
107
+ _copy = mpl .rcParams .copy ()
108
+ for key in six .iterkeys (_copy ):
109
+ mpl .rcParams [key ] = _copy [key ]
110
+ mpl .rcParams ['text.dvipnghack' ] = None
111
+ with mpl .rc_context ():
112
+ from copy import deepcopy
113
+ _deep_copy = deepcopy (mpl .rcParams )
114
+ from matplotlib .rcsetup import validate_bool_maybe_none , validate_bool
115
+ # real test is that this does not raise
116
+ assert_true (validate_bool_maybe_none (None ) is None )
117
+ assert_true (validate_bool_maybe_none ("none" ) is None )
118
+ _fonttype = mpl .rcParams ['svg.fonttype' ]
119
+ assert_true (_fonttype == mpl .rcParams ['svg.embed_char_paths' ])
120
+ with mpl .rc_context ():
121
+ mpl .rcParams ['svg.embed_char_paths' ] = False
122
+ assert_true (mpl .rcParams ['svg.fonttype' ] == "none" )
120
123
121
124
def test_Bug_2543_newer_python ():
122
- # only split from above because of the usage of assert_raises
125
+ # only split from above because of the usage of assert_raises
123
126
# as a context manager, which only works in 2.7 and above
124
127
if sys .version_info [:2 ] < (2 , 7 ):
125
128
raise nose .SkipTest ("assert_raises as context manager not supported with Python < 2.7" )
@@ -130,8 +133,8 @@ def test_Bug_2543_newer_python():
130
133
validate_bool (None )
131
134
with assert_raises (ValueError ):
132
135
with mpl .rc_context ():
133
- mpl .rcParams ['svg.fonttype' ] = True
134
-
136
+ mpl .rcParams ['svg.fonttype' ] = True
137
+
135
138
if __name__ == '__main__' :
136
139
import nose
137
140
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments