Skip to content
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 BF for Keithley 485 #285

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

trappitsch
Copy link
Contributor

Test suite now includes full coverage.

Bug fixes:

  • Quantities error corrected
  • If statement for error raising corrected, previous comparison was
    impossible to achieve
  • Error catching in _parse_measurement. Errors were previously raised
    in a try, except statement, however, the wrong error messages
    would be displayed if these errors in fact got raised

Test suite now includes full coverage.

Bug fixes:
- Quantities error corrected
- If statement for error raising corrected, previous comparison was
  impossible to achieve
- Error catching in `_parse_measurement`. Errors were previously raised
  in a `try`, `except` statement, however, the wrong error messages
  would be displayed if these errors in fact got raised
@@ -201,7 +201,7 @@ def input_range(self, newval):
raise ValueError("Only `auto` is acceptable when specifying "
"the range as a string.")
if isinstance(newval, u.Quantity):
newval = float(newval)
newval = float(newval.magnitude)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple correction, would have thrown an error otherwise.

@@ -334,7 +334,7 @@ def _get_status_word(self):
statusword = self.query("U0X")
tries -= 1

if statusword is None:
if tries == 0:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above, statusword = "" is introduced. Then instrument reads are tried several times. statusword can never be None. An if statusword comparison alone furthermore would not do the job in case the instrument returns something invalid. The while loop would still continue in this case until it runs out of tries, and the statusword returned would be bogus.
Checking for tries==0 avoids this issue.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 98.476% when pulling ed0263e on trappitsch:tests_bf_keithley485 into c739ca0 on Galvant:master.

if function != b"DC":
raise ValueError("Instrument not returning DC function: {}".format(function))

try:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous statement tried to get the status, then tried to see what status it is in a try statement. If one of the if statements inside the try pass, they will raise an error, which would jump to the except and raise another error message than the one that should be raised.
Now trying to read to get the statusword from the respective enum class first. If not possible, then raise a respective error. After that we can go into the if statements and check the constraints, if they fail, they will now return the correct error message.

@scasagrande
Copy link
Contributor

lgtm!

@scasagrande scasagrande merged commit e3f2764 into instrumentkit:master Nov 13, 2020
@trappitsch trappitsch deleted the tests_bf_keithley485 branch November 13, 2020 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants