-
-
Notifications
You must be signed in to change notification settings - Fork 139
Add remote/local handling for VXI-11 and HiSLIP #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f6adc8c
support vxi-11 remote/local
hb020 c193bc3
add hislip
hb020 bb07dfa
ran precommit
hb020 a247d28
add PR number
hb020 df50cfb
after review
hb020 b911d9b
ruff adapt
hb020 4626260
move dict
hb020 a81f269
final dict
hb020 35d01df
ruff
hb020 f1bc283
Update pyvisa_py/tcpip.py
hb020 c4cd59d
Update pyvisa_py/tcpip.py
hb020 1141ec3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """Unit tests for VXI11 and hislip remote/local operations.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from unittest.mock import MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from pyvisa import constants | ||
| from pyvisa_py.tcpip import TCPIPInstrHiSLIP, TCPIPInstrVxi11 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "mode, expected_method", | ||
| [ | ||
| (constants.RENLineOperation.address_gtl, "device_local"), | ||
| (constants.RENLineOperation.asrt_address, "device_remote"), | ||
| (constants.RENLineOperation.asrt_address_llo, "device_remote"), | ||
| (constants.RENLineOperation.deassert_gtl, "device_local"), | ||
| ], | ||
| ) | ||
| def test_vxi11_gpib_control_ren_calls_expected_device_method(mode, expected_method): | ||
| session = object.__new__(TCPIPInstrVxi11) | ||
| session.interface = MagicMock() | ||
| session.link = 7 | ||
| session.lock_timeout = 1234 | ||
| session._io_timeout = 5678 | ||
|
|
||
| session.interface.device_local.return_value = 0 | ||
| session.interface.device_remote.return_value = 0 | ||
|
|
||
| assert session.gpib_control_ren(mode) == constants.StatusCode.success | ||
|
|
||
| getattr(session.interface, expected_method).assert_called_once_with( | ||
| session.link, 0, session.lock_timeout, session._io_timeout | ||
| ) | ||
|
|
||
| if expected_method == "device_remote": | ||
| session.interface.device_local.assert_not_called() | ||
| else: | ||
| session.interface.device_remote.assert_not_called() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("invalid_mode", [-1, 999, "bogus", None, object()]) | ||
| def test_vxi11_gpib_control_ren_rejects_unsupported_modes(invalid_mode): | ||
| session = object.__new__(TCPIPInstrVxi11) | ||
| session.interface = MagicMock() | ||
| session.link = 7 | ||
| session.lock_timeout = 1234 | ||
| session._io_timeout = 5678 | ||
|
|
||
| assert session.gpib_control_ren(invalid_mode) == ( | ||
| constants.StatusCode.error_nonsupported_operation | ||
| ) | ||
| session.interface.device_local.assert_not_called() | ||
| session.interface.device_remote.assert_not_called() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "mode, expected_method", | ||
| [ | ||
| (constants.RENLineOperation.address_gtl, "justGTL"), | ||
| (constants.RENLineOperation.asrt, "enableRemote"), | ||
| (constants.RENLineOperation.asrt_address, "enableAndGotoRemote"), | ||
| (constants.RENLineOperation.asrt_address_llo, "enableAndGTRLLO"), | ||
| (constants.RENLineOperation.asrt_llo, "enableAndLockoutLocal"), | ||
| (constants.RENLineOperation.deassert, "disableRemote"), | ||
| (constants.RENLineOperation.deassert_gtl, "disableAndGTL"), | ||
| ], | ||
| ) | ||
| def test_hislip_gpib_control_ren_calls_expected_interface_method(mode, expected_method): | ||
| session = object.__new__(TCPIPInstrHiSLIP) | ||
| session.interface = MagicMock() | ||
|
|
||
| assert session.gpib_control_ren(mode) == constants.StatusCode.success | ||
| session.interface.async_remote_local_control.assert_called_once_with( | ||
| expected_method | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("invalid_mode", [-1, 999, "bogus", None, object()]) | ||
| def test_hislip_gpib_control_ren_rejects_unsupported_modes(invalid_mode): | ||
| session = object.__new__(TCPIPInstrHiSLIP) | ||
| session.interface = MagicMock() | ||
|
|
||
| assert session.gpib_control_ren(invalid_mode) == ( | ||
| constants.StatusCode.error_nonsupported_operation | ||
| ) | ||
| session.interface.async_remote_local_control.assert_not_called() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous comment on making this a module/class constant still applies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved. I kept the passage from one dict to another (in hislip.py), as this keeps it readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done