@@ -105,7 +105,7 @@ def side_effect(*args, **kwargs):
105105
106106 def test_01_k2400_iv_backend (self ):
107107 # GLOBAL PATCH for sleep is critical here
108- with patch ('pymeasure.instruments.keithley.Keithley2400' ) as MockInst , \
108+ with patch ('pymeasure.instruments.keithley.Keithley2400' , autospec = True ) as MockInst , \
109109 patch ('time.sleep' , side_effect = self .get_circuit_breaker (5 )):
110110
111111 spy = MockInst .return_value
@@ -123,10 +123,15 @@ def test_02_lakeshore_backend(self):
123123 spy .query .side_effect = [
124124 "LSCI,MODEL350,0,0" ] + ["10.0" , "300.0" ] * 20
125125
126+ # Create local mocks for matplotlib to avoid issues with global mocks
127+ mock_fig , mock_ax = MagicMock (), MagicMock ()
128+ mock_ax .plot .return_value = [MagicMock ()]
129+
126130 with patch ('builtins.input' , side_effect = ['10' , '300' , '10' , '350' ]), \
127131 patch ('builtins.open' , mock_open ()), \
128132 patch ('tkinter.filedialog.asksaveasfilename' , return_value = "test.csv" ), \
129- patch ('matplotlib.pyplot.show' ):
133+ patch ('matplotlib.pyplot.show' ), \
134+ patch ('matplotlib.pyplot.subplots' , return_value = (mock_fig , mock_ax )):
130135 self .run_module_safely (
131136 "Lakeshore_350_340.Backends.T_Control_L350_Simple_Backend_v10" )
132137
@@ -193,9 +198,9 @@ def test_08_combined_2400_2182(self):
193198 patch ('time.sleep' , side_effect = self .get_circuit_breaker (10 )):
194199
195200 rm = MockRM .return_value
196- # Ensure side_effect doesn't run out if script asks for many
197- # resources
198- rm .open_resource .return_value = MagicMock ()
201+ k2182_spy = MagicMock ()
202+ k2182_spy . assert_trigger = MagicMock ()
203+ rm .open_resource .return_value = k2182_spy
199204
200205 # Add extra inputs just in case the script asks for more than
201206 # expected
0 commit comments