Repository navigation
Conversation
jhenlely1
requested review from
amccann-Tek,
ldantek,
michaelwagoner,
nfelt14,
pradhansk,
tekperson and
v12ganesh
July 30, 2026 21:46
ldantek
reviewed
Aug 3, 2026
Contributor
|
I am concerned with expecting users to put raw passwords in the config file or their add_device function calls. |
nfelt14
requested changes
Aug 6, 2026
nfelt14
force-pushed
the
add-login-logout-support
branch
from
August 12, 2026 20:16
0feef78 to
c6e4f18
Compare
nfelt14
requested changes
Aug 12, 2026
Collaborator
|
You need to sign all of your commits |
jhenlely1
force-pushed
the
add-login-logout-support
branch
3 times, most recently
from
August 13, 2026 21:47
3eb5523 to
eaec63d
Compare
Collaborator
|
This branch needs to be rebased on main |
jhenlely1
force-pushed
the
add-login-logout-support
branch
from
August 19, 2026 18:13
eaec63d to
c74cb60
Compare
nfelt14
requested changes
Aug 19, 2026
jhenlely1
temporarily deployed
to
package-build
August 19, 2026 21:43 — with
GitHub Actions
Inactive
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
===========================================
- Coverage 100.00% 98.69% -1.31%
===========================================
Files 166 166
Lines 4866 4887 +21
Branches 437 441 +4
===========================================
- Hits 4866 4823 -43
- Misses 0 60 +60
- Partials 0 4 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhenlely1
force-pushed
the
add-login-logout-support
branch
from
August 21, 2026 16:00
15e5ed2 to
c6a45ba
Compare
jhenlely1
temporarily deployed
to
package-build
August 28, 2026 04:42 — with
GitHub Actions
Inactive
jhenlely1
force-pushed
the
add-login-logout-support
branch
from
September 8, 2026 12:58
c6a45ba to
3110ada
Compare
jhenlely1
temporarily deployed
to
package-build
September 8, 2026 15:40 — with
GitHub Actions
Inactive
Breaking API Changes |
Test Results (macos)
tests/test_smu.pydevice_manager = <tm_devices.device_manager.DeviceManager object at 0x11babc980>
capsys = <_pytest.capture.CaptureFixture object at 0x11d080520>
caplog = <_pytest.logging.LogCaptureFixture object at 0x11c03d810>
def test_smu( # noqa: PLR0915
device_manager: DeviceManager,
capsys: pytest.CaptureFixture[str],
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the SMU driver and TSP's IEEE commands.
Args:
device_manager: The DeviceManager object.
capsys: The captured stdout and stderr.
caplog: The captured log messages.
"""
smu: SMU2601B = device_manager.add_smu("smu2601b-hostname", alias="smu-device")
assert id(device_manager.get_smu(number_or_alias="smu-device")) == id(smu)
assert id(device_manager.get_smu(number_or_alias=smu.device_number)) == id(smu)
assert smu.manufacturer == "Keithley Instruments Inc."
assert smu.model == "Model 2601B"
assert smu.serial == "4498311"
assert smu.sw_version == Version("3.3.5")
with smu.command_syntax():
assert smu.commands.status.node_enable == "status.node_enable"
_ = capsys.readouterr() # throw away any stdout
with smu.command_verification():
smu.commands.status.node_enable = 1
stdout = capsys.readouterr().out
assert "Write" in stdout
assert "Query" in stdout
smu.load_script(
"loadfuncs",
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
run_script=True,
to_nv_memory=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
smu.load_script(
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
script_name="tsp_function",
)
stdout = capsys.readouterr().out
assert "loadscript tsp_function" in stdout
assert "if tsp_function ~= nil then script.delete('tsp_function') end" in stdout
assert "endscript" in stdout
assert "tsp_function.save()" not in stdout
assert "tsp_function()" not in stdout
smu.expect_esr(0)
smu.load_script(
script_name="loadfuncs",
script_body=(Path(os.path.realpath(__file__)).parent / "samples" / "tsp_script.tsp")
.read_text()
.strip(),
run_script=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" not in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
with mock.patch("pyvisa.highlevel.VisaLibraryBase.clear", mock.MagicMock(return_value=None)):
assert smu.query_expect_timeout("INVALID?", timeout_ms=1) == ""
with (
mock.patch(
"pyvisa.resources.messagebased.MessageBasedResource.query",
mock.MagicMock(side_effect=visa.errors.Error("custom error")),
),
pytest.raises(visa.errors.Error),
):
smu.query_expect_timeout("INVALID?", timeout_ms=1)
assert smu.expect_esr(32, ("Command error", "No Error"))
with pytest.raises(AssertionError):
smu.expect_esr(32, ("ERROR",))
tspieee = smu._ieee_cmds # noqa: SLF001
# Currently there is no way to unit test the cls function. Called to get full coverage.
tspieee.cls()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.ese(300)
assert tspieee.ese(1) == "1"
assert tspieee.ese() == "1"
assert tspieee.esr() == "0"
assert tspieee.opc(True) == ""
assert tspieee.opc() == "1"
# Currently there is no way to unit test the rst function. Called to get full coverage.
tspieee.rst()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.sre(300)
assert tspieee.sre(1) == "1"
assert tspieee.sre() == "1"
assert tspieee.stb() == "1"
assert tspieee.tst() == "0"
# Currently there is no way to unit test the wai function. Called to get full coverage.
tspieee.wai()
smu.expect_esr(0)
# Test some generic device functionality
capsys.readouterr() # clear the buffer
cmd_arg_constants_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at "
f"{str(smu.command_argument_constants).split(' at ', maxsplit=1)[-1]}"
)
cmds_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at "
f"{str(smu.commands).split(' at ', maxsplit=1)[-1]}"
)
print(smu) # noqa: T201
expected_stdout = f"""{"=" * 45} SMU {smu.device_number} {"=" * 45}
<class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at {id(smu)}
address='SMU2601B-HOSTNAME'
alias='SMU-DEVICE'
all_channel_names_list=('a',)
command_argument_constants={cmd_arg_constants_repr}
command_syntax_enabled=False
command_verification_enabled=False
commands={cmds_repr}
config_entry={smu.config_entry!r}
connection_type='TCPIP'
default_visa_timeout={UNIT_TEST_TIMEOUT}
device_number={smu.device_number}
device_type='SMU'
enable_verification=True
hostname='SMU2601B-HOSTNAME'
idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
ieee_cmds={smu.ieee_cmds!r}
ip_address=''
is_open=True
login_command=None
logout_command=None
manufacturer='Keithley Instruments Inc.'
model='Model 2601B'
name='SMU {smu.device_number}'
name_and_alias='SMU {smu.device_number} "SMU-DEVICE"'
port=None
resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
serial='4498311'
series='SMU2601B'
sw_version=<Version('3.3.5')>
total_channels=1
verbose=True
visa_backend='{smu.visa_backend}'
visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
visa_timeout={UNIT_TEST_TIMEOUT}
{"=" * (97 + len(str(smu.device_number)) - 1)}
"""
stdout = capsys.readouterr().out
> assert stdout == expected_stdout
E assert '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 4767680464\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x11c8e7620>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x11c2d0910>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x11d07b700>\n ip_address=\'\'\n is_open=True\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n' == '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 4767680464\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x11c8e7620>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x11c2d0910>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x11d07b700>\n ip_address=\'\'\n is_open=True\n login_command=None\n logout_command=None\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n'
E
E ============================================= SMU 49 =============================================
E <class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at 4767680464
E address='SMU2601B-HOSTNAME'
E alias='SMU-DEVICE'
E all_channel_names_list=('a',)
E command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x11c8e7620>
E command_syntax_enabled=False
E command_verification_enabled=False
E commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x11c2d0910>
E config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: 'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)
E connection_type='TCPIP'
E default_visa_timeout=50
E device_number=49
E device_type='SMU'
E enable_verification=True
E hostname='SMU2601B-HOSTNAME'
E idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
E ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x11d07b700>
E ip_address=''
E is_open=True
E - login_command=None
E - logout_command=None
E manufacturer='Keithley Instruments Inc.'
E model='Model 2601B'
E name='SMU 49'
E name_and_alias='SMU 49 "SMU-DEVICE"'
E port=None
E resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
E serial='4498311'
E series='SMU2601B'
E sw_version=<Version('3.3.5')>
E total_channels=1
E verbose=True
E visa_backend='PyVISA-sim'
E visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
E visa_timeout=50
E ==================================================================================================
_ = CaptureResult(out='2026-09-08 15:42:05.000564 - Creating Connection to SMU 49 "SMU-DEVICE"\n2026-09-08 15:42:05.000564 - SMU "SMU-DEVICE" VISA timeout set to: 50.000ms\n2026-09-08 15:42:05.000565 - (SMU 49 "SMU-DEVICE") Query >> \'*IDN?\'\n2026-09-08 15:42:05.000565 - Response from \'*IDN?\' >> \'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n', err='')
caplog = <_pytest.logging.LogCaptureFixture object at 0x11c03d810>
capsys = <_pytest.capture.CaptureFixture object at 0x11d080520>
cmd_arg_constants_repr = ('<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at '
'0x11c8e7620>')
cmds_repr = '<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x11c2d0910>'
device_manager = <tm_devices.device_manager.DeviceManager object at 0x11babc980>
expected_stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 4767680464\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x11c8e7620>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x11c2d0910>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x11d07b700>\n'
" ip_address=''\n"
' is_open=True\n'
' login_command=None\n'
' logout_command=None\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
smu = <tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B object at 0x11c2d07d0>
stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 4767680464\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x11c8e7620>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x11c2d0910>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x11d07b700>\n'
" ip_address=''\n"
' is_open=True\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
tspieee = <tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x11d07b700>
tests/test_smu.py:187: AssertionError |
Test Results (ubuntu)
tests/test_smu.pydevice_manager = <tm_devices.device_manager.DeviceManager object at 0x7fbf226b5e80>
capsys = <_pytest.capture.CaptureFixture object at 0x7fbf209599c0>
caplog = <_pytest.logging.LogCaptureFixture object at 0x7fbf20ff3490>
def test_smu( # noqa: PLR0915
device_manager: DeviceManager,
capsys: pytest.CaptureFixture[str],
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the SMU driver and TSP's IEEE commands.
Args:
device_manager: The DeviceManager object.
capsys: The captured stdout and stderr.
caplog: The captured log messages.
"""
smu: SMU2601B = device_manager.add_smu("smu2601b-hostname", alias="smu-device")
assert id(device_manager.get_smu(number_or_alias="smu-device")) == id(smu)
assert id(device_manager.get_smu(number_or_alias=smu.device_number)) == id(smu)
assert smu.manufacturer == "Keithley Instruments Inc."
assert smu.model == "Model 2601B"
assert smu.serial == "4498311"
assert smu.sw_version == Version("3.3.5")
with smu.command_syntax():
assert smu.commands.status.node_enable == "status.node_enable"
_ = capsys.readouterr() # throw away any stdout
with smu.command_verification():
smu.commands.status.node_enable = 1
stdout = capsys.readouterr().out
assert "Write" in stdout
assert "Query" in stdout
smu.load_script(
"loadfuncs",
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
run_script=True,
to_nv_memory=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
smu.load_script(
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
script_name="tsp_function",
)
stdout = capsys.readouterr().out
assert "loadscript tsp_function" in stdout
assert "if tsp_function ~= nil then script.delete('tsp_function') end" in stdout
assert "endscript" in stdout
assert "tsp_function.save()" not in stdout
assert "tsp_function()" not in stdout
smu.expect_esr(0)
smu.load_script(
script_name="loadfuncs",
script_body=(Path(os.path.realpath(__file__)).parent / "samples" / "tsp_script.tsp")
.read_text()
.strip(),
run_script=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" not in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
with mock.patch("pyvisa.highlevel.VisaLibraryBase.clear", mock.MagicMock(return_value=None)):
assert smu.query_expect_timeout("INVALID?", timeout_ms=1) == ""
with (
mock.patch(
"pyvisa.resources.messagebased.MessageBasedResource.query",
mock.MagicMock(side_effect=visa.errors.Error("custom error")),
),
pytest.raises(visa.errors.Error),
):
smu.query_expect_timeout("INVALID?", timeout_ms=1)
assert smu.expect_esr(32, ("Command error", "No Error"))
with pytest.raises(AssertionError):
smu.expect_esr(32, ("ERROR",))
tspieee = smu._ieee_cmds # noqa: SLF001
# Currently there is no way to unit test the cls function. Called to get full coverage.
tspieee.cls()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.ese(300)
assert tspieee.ese(1) == "1"
assert tspieee.ese() == "1"
assert tspieee.esr() == "0"
assert tspieee.opc(True) == ""
assert tspieee.opc() == "1"
# Currently there is no way to unit test the rst function. Called to get full coverage.
tspieee.rst()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.sre(300)
assert tspieee.sre(1) == "1"
assert tspieee.sre() == "1"
assert tspieee.stb() == "1"
assert tspieee.tst() == "0"
# Currently there is no way to unit test the wai function. Called to get full coverage.
tspieee.wai()
smu.expect_esr(0)
# Test some generic device functionality
capsys.readouterr() # clear the buffer
cmd_arg_constants_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at "
f"{str(smu.command_argument_constants).split(' at ', maxsplit=1)[-1]}"
)
cmds_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at "
f"{str(smu.commands).split(' at ', maxsplit=1)[-1]}"
)
print(smu) # noqa: T201
expected_stdout = f"""{"=" * 45} SMU {smu.device_number} {"=" * 45}
<class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at {id(smu)}
address='SMU2601B-HOSTNAME'
alias='SMU-DEVICE'
all_channel_names_list=('a',)
command_argument_constants={cmd_arg_constants_repr}
command_syntax_enabled=False
command_verification_enabled=False
commands={cmds_repr}
config_entry={smu.config_entry!r}
connection_type='TCPIP'
default_visa_timeout={UNIT_TEST_TIMEOUT}
device_number={smu.device_number}
device_type='SMU'
enable_verification=True
hostname='SMU2601B-HOSTNAME'
idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
ieee_cmds={smu.ieee_cmds!r}
ip_address=''
is_open=True
login_command=None
logout_command=None
manufacturer='Keithley Instruments Inc.'
model='Model 2601B'
name='SMU {smu.device_number}'
name_and_alias='SMU {smu.device_number} "SMU-DEVICE"'
port=None
resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
serial='4498311'
series='SMU2601B'
sw_version=<Version('3.3.5')>
total_channels=1
verbose=True
visa_backend='{smu.visa_backend}'
visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
visa_timeout={UNIT_TEST_TIMEOUT}
{"=" * (97 + len(str(smu.device_number)) - 1)}
"""
stdout = capsys.readouterr().out
> assert stdout == expected_stdout
E assert '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 140458858088400\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x7fbf20f9ef90>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x7fbf2057bed0>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x7fbf1bfe2b70>\n ip_address=\'\'\n is_open=True\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n' == '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 140458858088400\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x7fbf20f9ef90>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x7fbf2057bed0>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x7fbf1bfe2b70>\n ip_address=\'\'\n is_open=True\n login_command=None\n logout_command=None\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n'
E
E ============================================= SMU 49 =============================================
E <class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at 140458858088400
E address='SMU2601B-HOSTNAME'
E alias='SMU-DEVICE'
E all_channel_names_list=('a',)
E command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x7fbf20f9ef90>
E command_syntax_enabled=False
E command_verification_enabled=False
E commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x7fbf2057bed0>
E config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: 'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)
E connection_type='TCPIP'
E default_visa_timeout=50
E device_number=49
E device_type='SMU'
E enable_verification=True
E hostname='SMU2601B-HOSTNAME'
E idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
E ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x7fbf1bfe2b70>
E ip_address=''
E is_open=True
E - login_command=None
E - logout_command=None
E manufacturer='Keithley Instruments Inc.'
E model='Model 2601B'
E name='SMU 49'
E name_and_alias='SMU 49 "SMU-DEVICE"'
E port=None
E resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
E serial='4498311'
E series='SMU2601B'
E sw_version=<Version('3.3.5')>
E total_channels=1
E verbose=True
E visa_backend='PyVISA-sim'
E visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
E visa_timeout=50
E ==================================================================================================
_ = CaptureResult(out='2026-09-08 15:42:21.000633 - Creating Connection to SMU 49 "SMU-DEVICE"\n2026-09-08 15:42:21.000633 - SMU "SMU-DEVICE" VISA timeout set to: 50.000ms\n2026-09-08 15:42:21.000633 - (SMU 49 "SMU-DEVICE") Query >> \'*IDN?\'\n2026-09-08 15:42:21.000634 - Response from \'*IDN?\' >> \'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n', err='')
caplog = <_pytest.logging.LogCaptureFixture object at 0x7fbf20ff3490>
capsys = <_pytest.capture.CaptureFixture object at 0x7fbf209599c0>
cmd_arg_constants_repr = ('<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at '
'0x7fbf20f9ef90>')
cmds_repr = ('<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at '
'0x7fbf2057bed0>')
device_manager = <tm_devices.device_manager.DeviceManager object at 0x7fbf226b5e80>
expected_stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 140458858088400\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x7fbf20f9ef90>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x7fbf2057bed0>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x7fbf1bfe2b70>\n'
" ip_address=''\n"
' is_open=True\n'
' login_command=None\n'
' logout_command=None\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
smu = <tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B object at 0x7fbf205787d0>
stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 140458858088400\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x7fbf20f9ef90>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x7fbf2057bed0>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x7fbf1bfe2b70>\n'
" ip_address=''\n"
' is_open=True\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
tspieee = <tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x7fbf1bfe2b70>
tests/test_smu.py:187: AssertionError |
Test Results (windows)
tests\test_smu.pydevice_manager = <tm_devices.device_manager.DeviceManager object at 0x000001ACD7E4B0E0>
capsys = <_pytest.capture.CaptureFixture object at 0x000001ACDA2D9910>
caplog = <_pytest.logging.LogCaptureFixture object at 0x000001ACD886BCE0>
def test_smu( # noqa: PLR0915
device_manager: DeviceManager,
capsys: pytest.CaptureFixture[str],
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the SMU driver and TSP's IEEE commands.
Args:
device_manager: The DeviceManager object.
capsys: The captured stdout and stderr.
caplog: The captured log messages.
"""
smu: SMU2601B = device_manager.add_smu("smu2601b-hostname", alias="smu-device")
assert id(device_manager.get_smu(number_or_alias="smu-device")) == id(smu)
assert id(device_manager.get_smu(number_or_alias=smu.device_number)) == id(smu)
assert smu.manufacturer == "Keithley Instruments Inc."
assert smu.model == "Model 2601B"
assert smu.serial == "4498311"
assert smu.sw_version == Version("3.3.5")
with smu.command_syntax():
assert smu.commands.status.node_enable == "status.node_enable"
_ = capsys.readouterr() # throw away any stdout
with smu.command_verification():
smu.commands.status.node_enable = 1
stdout = capsys.readouterr().out
assert "Write" in stdout
assert "Query" in stdout
smu.load_script(
"loadfuncs",
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
run_script=True,
to_nv_memory=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
smu.load_script(
file_path=f"{Path(os.path.realpath(__file__)).parent}/samples/tsp_script.tsp",
script_name="tsp_function",
)
stdout = capsys.readouterr().out
assert "loadscript tsp_function" in stdout
assert "if tsp_function ~= nil then script.delete('tsp_function') end" in stdout
assert "endscript" in stdout
assert "tsp_function.save()" not in stdout
assert "tsp_function()" not in stdout
smu.expect_esr(0)
smu.load_script(
script_name="loadfuncs",
script_body=(Path(os.path.realpath(__file__)).parent / "samples" / "tsp_script.tsp")
.read_text()
.strip(),
run_script=True,
)
stdout = capsys.readouterr().out
assert "loadscript loadfuncs" in stdout
assert "if loadfuncs ~= nil then script.delete('loadfuncs') end" in stdout
assert "endscript" in stdout
assert "loadfuncs.save()" not in stdout
assert "loadfuncs()" in stdout
smu.expect_esr(0)
with mock.patch("pyvisa.highlevel.VisaLibraryBase.clear", mock.MagicMock(return_value=None)):
assert smu.query_expect_timeout("INVALID?", timeout_ms=1) == ""
with (
mock.patch(
"pyvisa.resources.messagebased.MessageBasedResource.query",
mock.MagicMock(side_effect=visa.errors.Error("custom error")),
),
pytest.raises(visa.errors.Error),
):
smu.query_expect_timeout("INVALID?", timeout_ms=1)
assert smu.expect_esr(32, ("Command error", "No Error"))
with pytest.raises(AssertionError):
smu.expect_esr(32, ("ERROR",))
tspieee = smu._ieee_cmds # noqa: SLF001
# Currently there is no way to unit test the cls function. Called to get full coverage.
tspieee.cls()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.ese(300)
assert tspieee.ese(1) == "1"
assert tspieee.ese() == "1"
assert tspieee.esr() == "0"
assert tspieee.opc(True) == ""
assert tspieee.opc() == "1"
# Currently there is no way to unit test the rst function. Called to get full coverage.
tspieee.rst()
with pytest.raises(
ValueError, match=r"value=300 is not a valid value\. The value must be between 0 and 255\."
):
tspieee.sre(300)
assert tspieee.sre(1) == "1"
assert tspieee.sre() == "1"
assert tspieee.stb() == "1"
assert tspieee.tst() == "0"
# Currently there is no way to unit test the wai function. Called to get full coverage.
tspieee.wai()
smu.expect_esr(0)
# Test some generic device functionality
capsys.readouterr() # clear the buffer
cmd_arg_constants_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at "
f"{str(smu.command_argument_constants).split(' at ', maxsplit=1)[-1]}"
)
cmds_repr = (
f"<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at "
f"{str(smu.commands).split(' at ', maxsplit=1)[-1]}"
)
print(smu) # noqa: T201
expected_stdout = f"""{"=" * 45} SMU {smu.device_number} {"=" * 45}
<class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at {id(smu)}
address='SMU2601B-HOSTNAME'
alias='SMU-DEVICE'
all_channel_names_list=('a',)
command_argument_constants={cmd_arg_constants_repr}
command_syntax_enabled=False
command_verification_enabled=False
commands={cmds_repr}
config_entry={smu.config_entry!r}
connection_type='TCPIP'
default_visa_timeout={UNIT_TEST_TIMEOUT}
device_number={smu.device_number}
device_type='SMU'
enable_verification=True
hostname='SMU2601B-HOSTNAME'
idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
ieee_cmds={smu.ieee_cmds!r}
ip_address=''
is_open=True
login_command=None
logout_command=None
manufacturer='Keithley Instruments Inc.'
model='Model 2601B'
name='SMU {smu.device_number}'
name_and_alias='SMU {smu.device_number} "SMU-DEVICE"'
port=None
resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
serial='4498311'
series='SMU2601B'
sw_version=<Version('3.3.5')>
total_channels=1
verbose=True
visa_backend='{smu.visa_backend}'
visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
visa_timeout={UNIT_TEST_TIMEOUT}
{"=" * (97 + len(str(smu.device_number)) - 1)}
"""
stdout = capsys.readouterr().out
> assert stdout == expected_stdout
E assert '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 1841903629520\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x000001ACD859BB60>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x000001ACDA02F610>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x000001ACD9AE9270>\n ip_address=\'\'\n is_open=True\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n' == '============================================= SMU 49 =============================================\n <class \'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B\'> object at 1841903629520\n address=\'SMU2601B-HOSTNAME\'\n alias=\'SMU-DEVICE\'\n all_channel_names_list=(\'a\',)\n command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x000001ACD859BB60>\n command_syntax_enabled=False\n command_verification_enabled=False\n commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x000001ACDA02F610>\n config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: \'SMU\'>, address=\'SMU2601B-HOSTNAME\', connection_type=<ConnectionTypes.TCPIP: \'TCPIP\'>, alias=\'SMU-DEVICE\', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)\n connection_type=\'TCPIP\'\n default_visa_timeout=50\n device_number=49\n device_type=\'SMU\'\n enable_verification=True\n hostname=\'SMU2601B-HOSTNAME\'\n idn_string=\'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x000001ACD9AE9270>\n ip_address=\'\'\n is_open=True\n login_command=None\n logout_command=None\n manufacturer=\'Keithley Instruments Inc.\'\n model=\'Model 2601B\'\n name=\'SMU 49\'\n name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n port=None\n resource_expression=\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\'\n serial=\'4498311\'\n series=\'SMU2601B\'\n sw_version=<Version(\'3.3.5\')>\n total_channels=1\n verbose=True\n visa_backend=\'PyVISA-sim\'\n visa_resource=<\'TCPIPInstrument\'(\'TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR\')>\n visa_timeout=50\n==================================================================================================\n'
E
E ============================================= SMU 49 =============================================
E <class 'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object at 1841903629520
E address='SMU2601B-HOSTNAME'
E alias='SMU-DEVICE'
E all_channel_names_list=('a',)
E command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at 0x000001ACD859BB60>
E command_syntax_enabled=False
E command_verification_enabled=False
E commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at 0x000001ACDA02F610>
E config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: 'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, serial_config=None, device_driver=None, login_command=None, logout_command=None, gpib_board_number=None)
E connection_type='TCPIP'
E default_visa_timeout=50
E device_number=49
E device_type='SMU'
E enable_verification=True
E hostname='SMU2601B-HOSTNAME'
E idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'
E ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x000001ACD9AE9270>
E ip_address=''
E is_open=True
E - login_command=None
E - logout_command=None
E manufacturer='Keithley Instruments Inc.'
E model='Model 2601B'
E name='SMU 49'
E name_and_alias='SMU 49 "SMU-DEVICE"'
E port=None
E resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'
E serial='4498311'
E series='SMU2601B'
E sw_version=<Version('3.3.5')>
E total_channels=1
E verbose=True
E visa_backend='PyVISA-sim'
E visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>
E visa_timeout=50
E ==================================================================================================
_ = CaptureResult(out='2026-09-08 15:43:07.000452 - Creating Connection to SMU 49 "SMU-DEVICE"\n2026-09-08 15:43:07.000453 - SMU "SMU-DEVICE" VISA timeout set to: 50.000ms\n2026-09-08 15:43:07.000453 - (SMU 49 "SMU-DEVICE") Query >> \'*IDN?\'\n2026-09-08 15:43:07.000454 - Response from \'*IDN?\' >> \'Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5\'\n', err='')
caplog = <_pytest.logging.LogCaptureFixture object at 0x000001ACD886BCE0>
capsys = <_pytest.capture.CaptureFixture object at 0x000001ACDA2D9910>
cmd_arg_constants_repr = ('<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants object at '
'0x000001ACD859BB60>')
cmds_repr = ('<tm_devices.commands.smu2601b_commands.SMU2601BCommands object at '
'0x000001ACDA02F610>')
device_manager = <tm_devices.device_manager.DeviceManager object at 0x000001ACD7E4B0E0>
expected_stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 1841903629520\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x000001ACD859BB60>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x000001ACDA02F610>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x000001ACD9AE9270>\n'
" ip_address=''\n"
' is_open=True\n'
' login_command=None\n'
' logout_command=None\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
smu = <tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B object at 0x000001ACDA02F4D0>
stdout = ('============================================= SMU 49 '
'=============================================\n'
' <class '
"'tm_devices.drivers.source_measure_units.smu26xx.smu2601b.SMU2601B'> object "
'at 1841903629520\n'
" address='SMU2601B-HOSTNAME'\n"
" alias='SMU-DEVICE'\n"
" all_channel_names_list=('a',)\n"
' '
'command_argument_constants=<tm_devices.commands.smu2601b_commands.SMU2601BCommandConstants '
'object at 0x000001ACD859BB60>\n'
' command_syntax_enabled=False\n'
' command_verification_enabled=False\n'
' commands=<tm_devices.commands.smu2601b_commands.SMU2601BCommands object '
'at 0x000001ACDA02F610>\n'
" config_entry=DeviceConfigEntry(device_type=<DeviceTypes.SMU: 'SMU'>, "
"address='SMU2601B-HOSTNAME', connection_type=<ConnectionTypes.TCPIP: "
"'TCPIP'>, alias='SMU-DEVICE', lan_port=None, lan_device_endpoint=None, "
'serial_config=None, device_driver=None, login_command=None, '
'logout_command=None, gpib_board_number=None)\n'
" connection_type='TCPIP'\n"
' default_visa_timeout=50\n'
' device_number=49\n'
" device_type='SMU'\n"
' enable_verification=True\n'
" hostname='SMU2601B-HOSTNAME'\n"
" idn_string='Keithley Instruments Inc., Model 2601B, 4498311, 3.3.5'\n"
' '
'ieee_cmds=<tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands '
'object at 0x000001ACD9AE9270>\n'
" ip_address=''\n"
' is_open=True\n'
" manufacturer='Keithley Instruments Inc.'\n"
" model='Model 2601B'\n"
" name='SMU 49'\n"
' name_and_alias=\'SMU 49 "SMU-DEVICE"\'\n'
' port=None\n'
" resource_expression='TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR'\n"
" serial='4498311'\n"
" series='SMU2601B'\n"
" sw_version=<Version('3.3.5')>\n"
' total_channels=1\n'
' verbose=True\n'
" visa_backend='PyVISA-sim'\n"
' '
"visa_resource=<'TCPIPInstrument'('TCPIP0::SMU2601B-HOSTNAME::inst0::INSTR')>\n"
' visa_timeout=50\n'
'==================================================================================================\n')
tspieee = <tm_devices.driver_mixins.shared_implementations.ieee488_2_commands.TSPIEEE4882Commands object at 0x000001ACD9AE9270>
tests\test_smu.py:187: AssertionError |
ldantek
reviewed
Sep 14, 2026
| visa_resource.read.return_value = idn_response | ||
| visa_resource.query.return_value = idn_response | ||
| visa_resource.timeout = 5000 | ||
| visa_resource.resource_info.resource_name = "TCPIP0::AFG3252C-HOSTNAME::inst0::INSTR" |
Contributor
There was a problem hiding this comment.
Does this device type actually have an option to use login commands? just making sure our examples are realistic since they are often referenced.
Collaborator
|
@jhenlely1, are you going to make the changes necessary to get this ready for merge? |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Added support for a user-specified
login_commandandlogout_commandin device config. These commands (e.g.login my_passwordandlogout) will get sent after initial device connection and before device connection closing respectively.This enables using tm_devices with instruments that are password protected.
Addresses #614
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Addresses #<issue_number>