From 84c27465797b8df4dee29ee845a3c9cea8ed1953 Mon Sep 17 00:00:00 2001 From: Dominik Kriegner Date: Wed, 28 Jun 2023 17:23:39 +0200 Subject: [PATCH] fix check_set_errors functions and improve tests previously the test did not cover any property setter. Also the check_set_errors function did not read back the additional termination characters. check_set_errors now returns a list upon success as required. --- pymeasure/instruments/mksinst/mks937b.py | 3 ++- tests/instruments/mksinst/test_mks937b.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pymeasure/instruments/mksinst/mks937b.py b/pymeasure/instruments/mksinst/mks937b.py index ab2265abe1..9a752cf9eb 100644 --- a/pymeasure/instruments/mksinst/mks937b.py +++ b/pymeasure/instruments/mksinst/mks937b.py @@ -155,7 +155,8 @@ def check_set_errors(self): reply = self._re_response.search(ret) if reply: if reply.group('ack') == 'ACK': - return + self._check_extra_termination() + return [] # no valid acknowledgement message found raise ValueError(f"invalid reply '{ret}' found in check_errors") diff --git a/tests/instruments/mksinst/test_mks937b.py b/tests/instruments/mksinst/test_mks937b.py index 4c9ea23aec..385b625dfa 100644 --- a/tests/instruments/mksinst/test_mks937b.py +++ b/tests/instruments/mksinst/test_mks937b.py @@ -57,8 +57,18 @@ def test_ion_gauge_status_invalid_channel(): inst.ch_2.ion_gauge_status -def test_unit(): - """Verify the communication of the voltage getter.""" +def test_unit_setter(): + """Verify the communication of the unit setter.""" + with expected_protocol( + MKS937B, + [("@253U!TORR", "@253ACKTORR"), + (None, b"FF")], + ) as inst: + inst.unit = "Torr" + + +def test_unit_getter(): + """Verify the communication of the unit getter.""" with expected_protocol( MKS937B, [("@253U?", "@253ACKTORR"), @@ -68,7 +78,7 @@ def test_unit(): def test_power_enabled(): - """Verify the communication of the voltage getter.""" + """Verify the communication of the channel power getter.""" with expected_protocol( MKS937B, [("@253CP1?", "@253ACKON"),