Skip to content

Commit e27dee0

Browse files
some corrections in tests
1 parent a6193b4 commit e27dee0

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

tests/test_deep_simulation.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,23 +201,19 @@ def test_08_combined_2400_2182(self):
201201
mock_sleep = patch('time.sleep', side_effect=self.get_circuit_breaker(10))
202202
mock_sleep.start()
203203
self.addCleanup(mock_sleep.stop)
204-
with patch('pyvisa.ResourceManager') as MockRM:
205-
mock_pymeasure = patch('pymeasure.instruments.keithley.Keithley2400')
206-
mock_pymeasure.start()
207-
204+
with patch('pyvisa.ResourceManager') as MockRM, \
205+
patch('pymeasure.instruments.keithley.Keithley2400'):
208206
rm = MockRM.return_value
209207
k2182_spy = MagicMock()
210208
k2182_spy.assert_trigger = MagicMock()
211209
rm.open_resource.return_value = k2182_spy
212210

213-
# Add extra inputs just in case the script asks for more than
214-
# expected
211+
# Add extra inputs just in case the script asks for more than expected
215212
inputs = ['10', '1', 'test_file', 'y', 'y', 'y', 'y']
216213
with patch('builtins.input', side_effect=inputs), \
217214
patch('pandas.DataFrame.to_csv'):
218215
self.run_module_safely(
219-
"pica.keithley.k2400.Keithley_2182.Instrument_Control.IV_K2400_K2182_Instrument_Control", {})
220-
mock_pymeasure.stop()
216+
"Keithley_2400_Keithley_2182.Backends.IV_K2400_K2182_Backend_v1", {})
221217

222218
@pytest.mark.usefixtures("mock_tkinter")
223219
def test_09_poling(self):

tests/test_gui_modules_initialization.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def test_gui_module_initialization(module_path):
5858
elif base_name.endswith('_GUI'):
5959
class_name = base_name
6060
else:
61-
pytest.fail(f"Could not determine class name from module path: {module_path}")
62-
61+
pytest.fail(f"Could not determine class name from module path: {module_path}")
6362

6463
# Get the class from the module and instantiate it
6564
AppClass = getattr(gui_module, class_name)

tests/test_package_integrity.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@ def test_has_docstring(file_path):
7474

7575
try:
7676
tree = ast.parse(source)
77-
if not (tree.body and isinstance(tree.body[0], ast.Expr) and isinstance(tree.body[0].value, (ast.Str, ast.Constant))):
77+
# A docstring is the first statement in a module and must be an expression
78+
# containing a string.
79+
# For Python < 3.8, this is ast.Str. For >= 3.8, it's ast.Constant holding a str.
80+
docstring_node = ast.get_docstring(tree, clean=False)
81+
82+
# ast.get_docstring returns the string value or None if not found.
83+
# We just need to know if it exists.
84+
if docstring_node is None:
7885
warnings.warn(f"JOSS STANDARD MISSING: {os.path.basename(file_path)} has no top-level docstring.", UserWarning)
79-
86+
8087
except SyntaxError:
8188
# Syntax errors are handled by the other test
8289
pass

0 commit comments

Comments
 (0)