File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import matplotlib as mpl
10
10
from matplotlib .backend_bases import MouseEvent
11
+ from matplotlib .font_manager import FontProperties
11
12
import matplotlib .patches as mpatches
12
13
import matplotlib .pyplot as plt
13
14
from matplotlib .testing .decorators import check_figures_equal , image_comparison
15
+ from matplotlib .text import Text
14
16
15
17
16
18
needs_usetex = pytest .mark .skipif (
@@ -689,3 +691,13 @@ def test_fontproperties_kwarg_precedence():
689
691
text2 = plt .ylabel ("counts" , size = 40.0 , fontproperties = 'Times New Roman' )
690
692
assert text1 .get_size () == 40.0
691
693
assert text2 .get_size () == 40.0
694
+
695
+
696
+ def test_update_mutate_input ():
697
+ inp = dict (fontproperties = FontProperties (weight = "bold" ),
698
+ bbox = None )
699
+ cache = dict (inp )
700
+ t = Text ()
701
+ t .update (inp )
702
+ assert inp ['fontproperties' ] == cache ['fontproperties' ]
703
+ assert inp ['bbox' ] == cache ['bbox' ]
Original file line number Diff line number Diff line change @@ -167,6 +167,8 @@ def __init__(self,
167
167
168
168
def update (self , kwargs ):
169
169
# docstring inherited
170
+ # make a copy so we do not mutate user input!
171
+ kwargs = dict (kwargs )
170
172
sentinel = object () # bbox can be None, so use another sentinel.
171
173
# Update fontproperties first, as it has lowest priority.
172
174
fontproperties = kwargs .pop ("fontproperties" , sentinel )
You can’t perform that action at this time.
0 commit comments