Skip to content

Commit 9e7a6e8

Browse files
The paths in test changes because of the name change to Instrument_Control
1 parent 2efd460 commit 9e7a6e8

4 files changed

Lines changed: 39 additions & 44 deletions

File tree

tests/test_backends_logic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def analyze_module_content(module):
4343
def test_lcr_backend_structure():
4444
with patch('pyvisa.ResourceManager'), patch('pyvisa.resources.MessageBasedResource'):
4545
try:
46-
from LCR_Keysight_E4980A.Backends import CV_KE4980A_Simple_Backend_v10 as LCR_Module
46+
from LCR_Keysight_E4980A.Instrument_Control import CV_KE4980A_Simple_Instrument_Control_v10 as LCR_Module
4747
except ImportError:
48-
pytest.skip("Could not import LCR Backend.")
48+
pytest.skip("Could not import LCR Instrument Control.")
4949

5050
category, obj = analyze_module_content(LCR_Module)
5151

@@ -68,9 +68,9 @@ def test_lcr_backend_structure():
6868
def test_delta_backend_structure():
6969
with patch('pyvisa.ResourceManager'):
7070
try:
71-
from Delta_mode_Keithley_6221_2182.Backends import Delta_K6221_K2182_Simple_v7 as Delta_Module
71+
from Delta_mode_Keithley_6221_2182.Instrument_Control import Delta_K6221_K2182_Simple_v7 as Delta_Module
7272
except ImportError:
73-
pytest.skip("Could not import Delta Backend.")
73+
pytest.skip("Could not import Delta Instrument Control.")
7474

7575
category, obj = analyze_module_content(Delta_Module)
7676

@@ -91,9 +91,9 @@ def test_delta_backend_structure():
9191
def test_k2400_backend_structure():
9292
with patch('pyvisa.ResourceManager'):
9393
try:
94-
from Keithley_2400.Backends import IV_K2400_Loop_Backend_v10 as K2400_Module
94+
from Keithley_2400.Instrument_Control import IV_K2400_Loop_Instrument_Control_v10 as K2400_Module
9595
except ImportError:
96-
pytest.skip("Could not import Keithley 2400 Backend.")
96+
pytest.skip("Could not import Keithley 2400 Instrument Control.")
9797

9898
category, obj = analyze_module_content(K2400_Module)
9999

tests/test_deep_simulation.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def test_01_k2400_iv_backend(self):
9999

100100
with patch('pymeasure.instruments.keithley.Keithley2400') as MockInst:
101101
spy = MockInst.return_value
102-
with patch('builtins.input', side_effect=['100', '10', 'test_file']),
103-
patch('pandas.DataFrame.to_csv'):
102+
with patch('builtins.input', side_effect=['100', '10', 'test_file']), \
103+
patch('pandas.DataFrame.to_csv'):
104104
self.run_module_safely(
105-
"Keithley_2400.Backends.IV_K2400_Loop_Backend_v10", {})
105+
"Keithley_2400.Instrument_Control.IV_K2400_Loop_Instrument_Control_v10", {})
106106
spy.enable_source.assert_called()
107107

108108
@pytest.mark.usefixtures("mock_tkinter")
@@ -111,13 +111,13 @@ def test_02_lakeshore_backend(self):
111111
mock_sleep.start()
112112
self.addCleanup(mock_sleep.stop)
113113
with patch('pyvisa.ResourceManager') as MockRM:
114-
spy = MockRM.return_value.open_resource.return_value # noqa
114+
spy = MockRM.return_value.open_resource.return_value
115115
spy.query.side_effect = [
116116
"LSCI,MODEL350,0,0"] + ["10.0", "300.0"] * 20
117117

118-
with patch('builtins.input', side_effect=['10', '300', '10', '350']),
119-
patch('builtins.open', mock_open()):
120-
self.run_module_safely("Lakeshore_350_340.Backends.T_Control_L350_Simple_Backend_v10", {})
118+
with patch('builtins.input', side_effect=['10', '300', '10', '350']), \
119+
patch('builtins.open', mock_open()):
120+
self.run_module_safely("Lakeshore_350_340.Instrument_Control.T_Control_L350_Simple_Instrument_Control_v10", {})
121121

122122
@pytest.mark.usefixtures("mock_tkinter")
123123
def test_03_k6517b_pyro_backend(self):
@@ -129,13 +129,13 @@ def test_03_k6517b_pyro_backend(self):
129129
spy.current = 1.23e-9
130130
with patch('pandas.DataFrame.to_csv'):
131131
self.run_module_safely(
132-
"Keithley_6517B.Pyroelectricity.Backends."
133-
"Current_K6517B_Simple_Backend_v10", {})
132+
"Keithley_6517B.Pyroelectricity.Instrument_Control."
133+
"Current_K6517B_Simple_Instrument_Control_v10", {})
134134

135135
@pytest.mark.usefixtures("mock_tkinter")
136136
def test_04_lcr_keysight_backend(self):
137137
with patch('pymeasure.instruments.agilent.AgilentE4980'), \
138-
patch('pyvisa.ResourceManager') as MockRM:
138+
patch('pyvisa.ResourceManager') as MockRM:
139139
mock_sleep = patch('time.sleep', side_effect=self.get_circuit_breaker(5))
140140
mock_sleep.start()
141141
self.addCleanup(mock_sleep.stop)
@@ -144,7 +144,7 @@ def test_04_lcr_keysight_backend(self):
144144
visa_spy.query.return_value = "0.5"
145145
with patch('pandas.DataFrame.to_csv'):
146146
self.run_module_safely(
147-
"LCR_Keysight_E4980A.Backends.CV_KE4980A_Simple_Backend_v10", {})
147+
"LCR_Keysight_E4980A.Instrument_Control.CV_KE4980A_Simple_Instrument_Control_v10", {})
148148

149149
@pytest.mark.usefixtures("mock_tkinter")
150150
def test_05_delta_simple(self):
@@ -154,9 +154,9 @@ def test_05_delta_simple(self):
154154
with patch('pyvisa.ResourceManager') as MockRM:
155155
MockRM.return_value.open_resource.return_value
156156
inputs = ['0', '1e-5', '1e-6', 'test_file', 'y', 'y']
157-
with patch('builtins.input', side_effect=inputs),
158-
patch('pandas.DataFrame.to_csv'):
159-
self.run_module_safely("Delta_mode_Keithley_6221_2182.Backends.Delta_K6221_K2182_Simple_v7", {})
157+
with patch('builtins.input', side_effect=inputs), \
158+
patch('pandas.DataFrame.to_csv'):
159+
self.run_module_safely("Delta_mode_Keithley_6221_2182.Instrument_Control.Delta_K6221_K2182_Simple_v7", {})
160160

161161
@pytest.mark.usefixtures("mock_tkinter")
162162
def test_06_delta_sensing(self):
@@ -168,11 +168,11 @@ def test_06_delta_sensing(self):
168168
inst = MockRM.return_value.open_resource.return_value
169169
inst.query.return_value = "+1.23E-5"
170170
inputs = ['10', '300', '10', 'test_file', 'y']
171-
with patch('builtins.input', side_effect=inputs),
172-
patch('pandas.DataFrame.to_csv'):
171+
with patch('builtins.input', side_effect=inputs), \
172+
patch('pandas.DataFrame.to_csv'):
173173
try:
174174
self.run_module_safely(
175-
"Delta_mode_Keithley_6221_2182.Backends.Delta_K6221_K2182_L350_T_Sensing_Backend_v1", {})
175+
"Delta_mode_Keithley_6221_2182.Instrument_Control.Delta_K6221_K2182_L350_T_Sensing_Instrument_Control_v1", {})
176176
except ModuleNotFoundError:
177177
print(" [SKIP] Module not found, skipping.")
178178

@@ -190,7 +190,7 @@ def test_07_lockin_backend(self):
190190
"1.23,4.56" # SNAP? 3,4
191191
]
192192
self.run_module_safely(
193-
"Lock_in_amplifier.BasicTest_S830_Backend_v1", {})
193+
"Lock_in_amplifier.BasicTest_S830_Instrument_Control_v1", {})
194194

195195
@pytest.mark.usefixtures("mock_tkinter")
196196
def test_08_combined_2400_2182(self):
@@ -211,10 +211,10 @@ def test_08_combined_2400_2182(self):
211211
# Add extra inputs just in case the script asks for more than
212212
# expected
213213
inputs = ['10', '1', 'test_file', 'y', 'y', 'y', 'y']
214-
with patch('builtins.input', side_effect=inputs),
215-
patch('pandas.DataFrame.to_csv'):
214+
with patch('builtins.input', side_effect=inputs), \
215+
patch('pandas.DataFrame.to_csv'):
216216
self.run_module_safely(
217-
"Keithley_2400_Keithley_2182.Backends.IV_K2400_K2182_Backend_v1", {})
217+
"Keithley_2400_Keithley_2182.Instrument_Control.IV_K2400_K2182_Instrument_Control_v1", {})
218218
mock_pymeasure.stop()
219219

220220
@pytest.mark.usefixtures("mock_tkinter")
@@ -226,7 +226,7 @@ def test_09_poling(self):
226226
inputs = ['100', '10', 'y']
227227
with patch('builtins.input', side_effect=inputs):
228228
self.run_module_safely(
229-
"Keithley_6517B.Pyroelectricity.Backends.Poling_K6517B_Backend_v10", {})
229+
"Keithley_6517B.Pyroelectricity.Instrument_Control.Poling_K6517B_Instrument_Control_v10", {})
230230

231231
@pytest.mark.usefixtures("mock_tkinter")
232232
def test_10_high_resistance(self):
@@ -242,9 +242,9 @@ def test_10_high_resistance(self):
242242
# Correct inputs for: start_v, stop_v, steps, delay, filename
243243
inputs = ['-10', '10', '5', '0.1', 'test_file']
244244

245-
with patch('builtins.input', side_effect=inputs),
246-
patch('builtins.open', mock_open()):
247-
self.run_module_safely("Keithley_6517B.High_Resistance.Backends.IV_K6517B_Simple_Backend_v10", {}) # noqa
245+
with patch('builtins.input', side_effect=inputs), \
246+
patch('builtins.open', mock_open()):
247+
self.run_module_safely("Keithley_6517B.High_Resistance.Instrument_Control.IV_K6517B_Simple_Instrument_Control_v10", {})
248248

249249
@pytest.mark.usefixtures("mock_tkinter")
250250
def test_11_gpib_scanner(self):
@@ -266,9 +266,9 @@ def test_12_gpib_rescue(self):
266266
self.addCleanup(mock_sleep.stop)
267267

268268
rm = MockRM.return_value
269-
rm.list_.resources.return_value = ('GPIB0::1::INSTR',)
269+
rm.list_resources.return_value = ('GPIB0::1::INSTR',)
270270
self.run_module_safely(
271-
"Utilities.GPIB_Interface_Rescue_Simple_Backened_v2_", {})
271+
"Utilities.GPIB_Interface_Rescue_Simple_Instrument_Control_v2_", {})
272272

273273

274274
if __name__ == '__main__':

tests/test_full_stack_simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_keithley2400_iv_protocol(self):
6161
with patch('builtins.input', side_effect=fake_inputs), \
6262
patch('pandas.DataFrame.to_csv'):
6363
self.run_module_safely(
64-
"Keithley_2400.Backends.IV_K2400_Loop_Backend_v10")
64+
"Keithley_2400.Instrument_Control.IV_K2400_Loop_Instrument_Control_v10")
6565

6666
# Assertions
6767
spy_inst.enable_source.assert_called()
@@ -120,7 +120,7 @@ def test_lakeshore_visa_communication(self):
120120
patch('tkinter.filedialog.asksaveasfilename', mock_file_dialog):
121121

122122
self.run_module_safely(
123-
"Lakeshore_350_340.Backends.T_Control_L350_Simple_Backend_v10")
123+
"Lakeshore_350_340.Instrument_Control.T_Control_L350_Simple_Instrument_Control_v10")
124124

125125
# --- ASSERTIONS ---
126126
# Now that the script runs fully without crashing on .plot(),

tests/test_package_integrity.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def test_syntax_compilation(file_path):
5151
# compile() is stricter than ast.parse(); it generates bytecode
5252
compile(source, filename=file_path, mode='exec')
5353
except SyntaxError as e:
54-
pytest.fail(f"CRITICAL SYNTAX ERROR in {os.path.basename(file_path)}:\n"
55-
f"Line {e.lineno}: {e.msg}\n"
54+
pytest.fail(f"CRITICAL SYNTAX ERROR in {os.path.basename(file_path)}:\n"
55+
f"Line {e.lineno}: {e.msg}\n"
5656
f"Code: {e.text}")
5757
except Exception as e:
5858
pytest.fail(f"File {os.path.basename(file_path)} could not be compiled. Error: {e}")
@@ -74,13 +74,8 @@ def test_has_docstring(file_path):
7474

7575
try:
7676
tree = ast.parse(source)
77-
# Check if the first node in the file is a Docstring (Expression -> Constant string)
78-
if not (tree.body and isinstance(tree.body[0], ast.Expr) and
79-
isinstance(tree.body[0].value, (ast.Str, ast.Constant))):
80-
81-
# This is a 'Warning' - it won't break code, but it fails JOSS standards
82-
warnings.warn(f"JOSS STANDARD MISSING: {os.path.basename(file_path)} has no top-level docstring. "
83-
"Please add a description at the top of the file using '""" ... """'.", UserWarning)
77+
if not (tree.body and isinstance(tree.body[0], ast.Expr) and isinstance(tree.body[0].value, (ast.Str, ast.Constant))):
78+
warnings.warn(f"JOSS STANDARD MISSING: {os.path.basename(file_path)} has no top-level docstring.", UserWarning)
8479

8580
except SyntaxError:
8681
# Syntax errors are handled by the other test

0 commit comments

Comments
 (0)