Closed LongnoseRob closed 1 year ago
Could add an entry to the docs ? Otherwise this looks good since we require pyserial >= 3.0 and this feature was introduced in 2.5
Could add an entry to the docs ? Otherwise this looks good since we require pyserial >= 3.0 and this feature was introduced in 2.5
Added some documentation, hope this is what you were thinking about.
What I am not sure about is how to add a test :thinking:
Thanks for the doc update I believe it will do. My only remaining concern is the behavior one gets if pyvisa attempts to read/write an attribute which is not supported for a URL. I did not dive deep enough in pyserial docs to have a clear sense of what would happen then.
As for testing since you can talk to the loop back you could mock a resource no ?
Thanks for the doc update I believe it will do. My only remaining concern is the behavior one gets if pyvisa attempts to read/write an attribute which is not supported for a URL. I did not dive deep enough in pyserial docs to have a clear sense of what would happen then.
If it try an assert_trigger()
on a loop:// resource, this causes a NotImplementedError
If I try a read_stb()
, this causes a VisaIOError: VI_ERROR_NSUP_OPER (-1073807257): The given session or object reference does not support this operation.
As for testing since you can talk to the loop back you could mock a resource no ?
WIll work on that next
added a unit test, but it seems i cannot trigger the test(s) from the cli on two systems with python 3.11.3 or 3.11.4:
~/builds/pyvisa-py$ python -m unittest pyvisa_py/testsuite/test_serial.py |
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
I may have switched to pytest at one point I will have to double check.
I may have switched to pytest at one point I will have to double check.
pytest seems to work (and also pointed out a deprecatuion issue..
CIs are not good. You may need to skip the new tests in some cases (note I did not check the exact failure).
CIs are not good. You may need to skip the new tests in some cases (note I did not check the exact failure).
The CI failed due to me using .append
instead of directly setting the value.
Could you trigger a new CI-run?
Could it be that in the CI enviromnent no pyserial
is available and therefore the test fails?
Proof:
(ptest) [robby@octoberrain pyvisa_py]$ pip list
Package Version Editable project location
----------------- --------------------- ----------------------------
coverage 7.2.7
iniconfig 2.0.0
packaging 23.1
pip 22.3.1
pluggy 1.2.0
pytest 7.4.0
pytest-cov 4.1.0
pytest-cover 3.0.0
pytest-coverage 0.0
PyVISA 1.13.1.dev31+g071fa6d /home/robby/builds/pyvisa
PyVISA-py 0.7.1.dev8+g5e0e5d6 /home/robby/builds/pyvisa-py
setuptools 65.5.0
typing_extensions 4.7.1
(ptest) [robby@octoberrain pyvisa_py]$ pytest testsuite/test_serial.py
============================================================================================================ test session starts ============================================================================================================
platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/robby/builds/pyvisa-py
configfile: pyproject.toml
plugins: cov-4.1.0
collected 1 item
testsuite/test_serial.py F [100%]
================================================================================================================= FAILURES ================================================================================================================== __ TestSerial.test_serial ___
self = <pyvisa_py.testsuite.test_serial.TestSerial object at 0x7fbf0e7fbdd0>
def test_serial(self):
"""Test loop://"""
msg = b"Test01234567890"
available = ["loop://"]
expected = []
exp_missing = []
missing = {}
rm = ResourceManager("@py")
try:
dut = rm.open_resource("ASRLloop://::INSTR")
print("opened")
dut.timeout = 3000
dut.read_termination = "\r\n"
dut.write_termination = "\r\n"
dut.write(str(msg))
ret_val = dut.read()
if str(msg) == ret_val:
expected = ["loop://"]
except Exception:
exp_missing = ["loop://"]
assert sorted(available) == sorted(expected)
E AssertionError: assert ['loop://'] == [] E Left contains one more item: 'loop://' E Use -v to get more diff
testsuite/test_serial.py:39: AssertionError
- install pyserial
(ptest) [robby@octoberrain pyvisa_py]$ pip list Package Version Editable project location
coverage 7.2.7 iniconfig 2.0.0 packaging 23.1 pip 22.3.1 pluggy 1.2.0 pyserial 3.5 <---- pytest 7.4.0 pytest-cov 4.1.0 pytest-cover 3.0.0 pytest-coverage 0.0 PyVISA 1.13.1.dev31+g071fa6d /home/robby/builds/pyvisa PyVISA-py 0.7.1.dev8+g5e0e5d6 /home/robby/builds/pyvisa-py setuptools 65.5.0 typing_extensions 4.7.1
- run test again:
(ptest) [robby@octoberrain pyvisa_py]$ pytest testsuite/test_serial.py ============================================================================================================ test session starts ============================================================================================================ platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0 rootdir: /home/robby/builds/pyvisa-py configfile: pyproject.toml plugins: cov-4.1.0 collected 1 item
testsuite/test_serial.py . [100%]
--> We need to extend the CI env to include pyserial for the tests
Can I do this in this PR or should this be done in anotherway?
I am fine with you adding to the CI env but I would also like to see the test behind a conditional skip if pyserial is not available.
I am fine with you adding to the CI env but I would also like to see the test behind a conditional skip if pyserial is not available.
Merging #386 (cdd8d32) into main (c33f4f2) will decrease coverage by
0.03%
. Report is 1 commits behind head on main. The diff coverage is18.51%
.
:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.
@@ Coverage Diff @@
## main #386 +/- ##
==========================================
- Coverage 23.05% 23.02% -0.03%
==========================================
Files 22 23 +1
Lines 3292 3318 +26
Branches 456 457 +1
==========================================
+ Hits 759 764 +5
- Misses 2516 2536 +20
- Partials 17 18 +1
Flag | Coverage Δ | |
---|---|---|
unittests | 23.02% <18.51%> (-0.03%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Files Changed | Coverage Δ | |
---|---|---|
pyvisa_py/serial.py | 5.71% <0.00%> (+0.02%) |
:arrow_up: |
pyvisa_py/testsuite/test_serial.py | 19.23% <19.23%> (ø) |
Thanks for the review.
to support loop:// and other url-types supported in pyserial (>3.0)
tested with the follwing code on python 3.11.3, pyserial 3.5:
black . && isort -c . && flake8
with no errors