File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4529,6 +4529,27 @@ def on_change(): # pyright: ignore[reportUnusedFunction]
45294529 assert changes == ['world' ]
45304530 assert 'side_var' in lf ._variables
45314531
4532+ def test_variables_clear_stops_notifications (self , config_kwargs : dict [str , Any ]):
4533+ """After variables_clear(), provider changes no longer notify anything."""
4534+ config = VariablesConfig (variables = {'my_var' : single_label_config ('my_var' , '"hello"' )})
4535+ config_kwargs ['variables' ] = LocalVariablesOptions (config = config )
4536+ lf = logfire .configure (** config_kwargs )
4537+ provider = lf .config .get_variable_provider ()
4538+ assert isinstance (provider , LocalVariableProvider )
4539+
4540+ my_var = lf .var ('my_var' , default = 'default' , type = str )
4541+
4542+ changes : list [str ] = []
4543+
4544+ @my_var .on_change
4545+ def on_change (): # pragma: no cover # pyright: ignore[reportUnusedFunction]
4546+ changes .append ('changed' )
4547+
4548+ lf .variables_clear ()
4549+ provider .update_variable ('my_var' , single_label_config ('my_var' , '"world"' ))
4550+
4551+ assert changes == []
4552+
45324553 def test_no_duplicate_notifications_after_clear_and_redefine (self , config_kwargs : dict [str , Any ]):
45334554 """variables_clear() followed by re-registration must not duplicate notifications."""
45344555 config = VariablesConfig (variables = {'my_var' : single_label_config ('my_var' , '"hello"' )})
You can’t perform that action at this time.
0 commit comments