-
Notifications
You must be signed in to change notification settings - Fork 71
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
Test suite and BFs for Tektronix TDS5xx #261
Test suite and BFs for Tektronix TDS5xx #261
Conversation
Test suite with full coverage - Tests for `get_hardcopy` routine is a bit creative, but couldn't find any manual entry for what is done there. Bug fixes: - Typos - map(float, list_of_string) not allowed anymore, switched to directly transferring to `np.array` with specific `dtype`. - `flush_input` in `read_waveform` replaced with reading one character. Manual states that newline character is present after binary block. - Enums called with name instead of value -> fixed, now called properly - `get_hardcopy` routine tried to unpack read data. However, the `read` routine already decodes it using "utf-8" as the default encoding already. Thus: need to encode again before using `struct.unpack` to unpack them. - Class had `import time` and `from time import sleep` and used `sleep` and `time.sleep`. Used `import time`, which is useful to mock out sleep time.
assert err_msg == f"Expected bool but got {type(wrong_type)} instead" | ||
|
||
|
||
def test_get_hardcopy(mocker): |
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 get_hardcopy
routine is weird to me. I can't seem to find it in the programmers manual. Furthermore, looking up header length for bmp
files, which I think should be transferred here, does not show a "standard" header length of 54, as is assumed here.
The test here is basically stiched together such that the routine is tested...
I dug through the archives and here is where it was originally merged in: #29 Obviously the comments are way out of date, but it looks like it was the first PR submitted by someone that I didn't already know. I completely forgot about that! |
Thanks @scasagrande that helps a lot. Now I know at least where this split between header and data comes from in the One more note: I've seen the issue before (and it's coming up in the uncovered Keithley classes) that a query expected to get binary data back. The return self.read_raw(size).decode(encoding) I assume this is something that was later added to ik as well and was not there originally? Does this justify that we simply have to encode reads again to make it compatible, as I've done above? As mentioned, this issue is about to come up in the missing tests for some Keithleys (that's the reason they are still missing). |
Yeah, we originally didn't differentiate between reading bytes and reading unicode. Part of that was due to ignorance, part was due to Python 2's handling of strings. So originally, everything would just use |
Test still worked, but now we can use hypothesis to simulate binary data.
Thanks for the explanation, this really helps. I switched the decode / encode things over to Now the test is also better, using hypothesis now to create binary data of random length, then stitch it together with a header to agree with the format and length of the header that is expected in the original code. I think this is as good as it will get w/o the hardware. |
lgtm |
Test suite with full coverage
get_hardcopy
routine is a bit creative, but couldn'tfind any manual entry for what is done there.
Bug fixes:
transferring to
np.array
with specificdtype
.flush_input
inread_waveform
replaced with reading one character.Manual states that newline character is present after binary block.
get_hardcopy
routine tried to unpack read data. However, theread
routine already decodes it using "utf-8" as the defaultencoding already. Thus: need to encode again before using
struct.unpack
to unpack them.import time
andfrom time import sleep
and usedsleep
and
time.sleep
. Usedimport time
, which is useful to mock outsleep time.