@@ -49,6 +49,49 @@ 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 ['deprecated.config.oldkey' ] = 'config.newkey'
54+ ct .config .defaults ['deprecated.config.oldmiss' ] = 'config.newmiss'
55+
56+ msgpattern = r'config\.oldkey.* has been renamed to .*config\.newkey'
57+
58+ ct .config .defaults ['config.newkey' ] = 1
59+ with pytest .warns (FutureWarning , match = msgpattern ):
60+ assert ct .config .defaults ['config.oldkey' ] == 1
61+ with pytest .warns (FutureWarning , match = msgpattern ):
62+ ct .config .defaults ['config.oldkey' ] = 2
63+ with pytest .warns (FutureWarning , 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 (FutureWarning , match = msgpattern ):
69+ assert ct .config ._get_param ('config' , 'oldkey' ) == 3
70+ with pytest .warns (FutureWarning , match = msgpattern ):
71+ ct .config .set_defaults ('config' , oldkey = 4 )
72+ with pytest .warns (FutureWarning , match = msgpattern ):
73+ assert ct .config .defaults ['config.oldkey' ] == 4
74+ assert ct .config .defaults ['config.newkey' ] == 4
75+
76+ ct .config .defaults .update ({'config.newkey' : 5 })
77+ with pytest .warns (FutureWarning , match = msgpattern ):
78+ ct .config .defaults .update ({'config.oldkey' : 6 })
79+ with pytest .warns (FutureWarning , match = msgpattern ):
80+ assert ct .config .defaults .get ('config.oldkey' ) == 6
81+
82+ with pytest .raises (KeyError ):
83+ with pytest .warns (FutureWarning , match = msgpattern ):
84+ ct .config .defaults ['config.oldmiss' ]
85+ with pytest .raises (KeyError ):
86+ ct .config .defaults ['config.neverdefined' ]
87+
88+ # assert that reset defaults keeps the custom type
89+ ct .config .reset_defaults ()
90+ with pytest .warns (FutureWarning ,
91+ match = 'bode.* has been renamed to.*freqplot' ):
92+ assert ct .config .defaults ['bode.Hz' ] \
93+ == ct .config .defaults ['freqplot.Hz' ]
94+
5295 @mplcleanup
5396 def test_fbs_bode (self ):
5497 ct .use_fbs_defaults ()
0 commit comments