@@ -49,6 +49,43 @@ def test_get_param(self):
4949
5050 assert ct .config ._get_param ('config' , 'test4' , {'test4' : 1 }, None ) == 1
5151
52+ def test_default_deprecation (self ):
53+ ct .config .defaults ['config.newkey' ] = 1
54+ ct .config .defaults ['deprecated.config.oldkey' ] = 'config.newkey'
55+ ct .config .defaults ['deprecated.config.oldmiss' ] = 'config.newmiss'
56+
57+ msgpattern = r'config\.oldkey.* has been renamed to .*config\.newkey'
58+
59+ with pytest .warns (DeprecationWarning , match = msgpattern ):
60+ assert ct .config .defaults ['config.oldkey' ] == 1
61+ with pytest .warns (DeprecationWarning , match = msgpattern ):
62+ ct .config .defaults ['config.oldkey' ] = 2
63+ with pytest .warns (DeprecationWarning , match = msgpattern ):
64+ assert ct .config .defaults ['config.oldkey' ] == 2
65+ assert ct .config .defaults ['config.newkey' ] == 2
66+
67+ ct .config .set_defaults ('config' , newkey = 3 )
68+ with pytest .warns (DeprecationWarning , match = msgpattern ):
69+ assert ct .config ._get_param ('config' , 'oldkey' ) == 3
70+ with pytest .warns (DeprecationWarning , match = msgpattern ):
71+ ct .config .set_defaults ('config' , oldkey = 4 )
72+ with pytest .warns (DeprecationWarning , match = msgpattern ):
73+ assert ct .config .defaults ['config.oldkey' ] == 4
74+ assert ct .config .defaults ['config.newkey' ] == 4
75+
76+ with pytest .raises (KeyError ):
77+ with pytest .warns (DeprecationWarning , match = msgpattern ):
78+ ct .config .defaults ['config.oldmiss' ]
79+ with pytest .raises (KeyError ):
80+ ct .config .defaults ['config.neverdefined' ]
81+
82+ # assert that reset defaults keeps the custom type
83+ ct .config .reset_defaults ()
84+ with pytest .warns (DeprecationWarning ,
85+ match = 'bode.* has been renamed to.*freqplot' ):
86+ assert ct .config .defaults ['bode.Hz' ] \
87+ == ct .config .defaults ['freqplot.Hz' ]
88+
5289 @mplcleanup
5390 def test_fbs_bode (self ):
5491 ct .use_fbs_defaults ()
0 commit comments