File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99import matplotlib as mpl
1010from matplotlib .backend_bases import MouseEvent
11+ from matplotlib .font_manager import FontProperties
1112import matplotlib .patches as mpatches
1213import matplotlib .pyplot as plt
1314from matplotlib .testing .decorators import check_figures_equal , image_comparison
15+ from matplotlib .text import Text
1416
1517
1618needs_usetex = pytest .mark .skipif (
@@ -689,3 +691,13 @@ def test_fontproperties_kwarg_precedence():
689691 text2 = plt .ylabel ("counts" , size = 40.0 , fontproperties = 'Times New Roman' )
690692 assert text1 .get_size () == 40.0
691693 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,
167167
168168 def update (self , kwargs ):
169169 # docstring inherited
170+ # make a copy so we do not mutate user input!
171+ kwargs = dict (kwargs )
170172 sentinel = object () # bbox can be None, so use another sentinel.
171173 # Update fontproperties first, as it has lowest priority.
172174 fontproperties = kwargs .pop ("fontproperties" , sentinel )
You can’t perform that action at this time.
0 commit comments