Skip to content

Commit

Permalink
Merge pull request pymeasure#1145 from kpet/fix-hp-test-issue
Browse files Browse the repository at this point in the history
Fix race condition in test suite due to HP8116A tests
  • Loading branch information
BenediktBurger authored Jul 31, 2024
2 parents 2524d7d + eff2020 commit a4f076a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ Nick James Kirkby
Konrad Gralher
David Ziliak
David Sun
Kévin Petit
16 changes: 10 additions & 6 deletions tests/instruments/hp/test_hp8116a.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,46 @@
from pymeasure.instruments.hp import HP8116A
from pymeasure.instruments.hp.hp8116a import Status

HP8116A.status = property(fget=lambda self: Status(5))

class HP8116AWithMockStatus(HP8116A):
@property
def status(self):
return Status(5)


init_comm = [(b"CST", b"x" * 87 + b' ,\r\n')] # communication during init


def test_init():
with expected_protocol(
HP8116A,
HP8116AWithMockStatus,
init_comm,
):
pass # Verify the expected communication.


def test_duty_cycle():
with expected_protocol(
HP8116A,
HP8116AWithMockStatus,
init_comm + [(b"IDTY", b"00000035")],
) as instr:
assert instr.duty_cycle == 35


def test_duty_cycle_setter():
with expected_protocol(
HP8116A,
HP8116AWithMockStatus,
init_comm + [(b"DTY 34.5 %", None)],
) as instr:
instr.duty_cycle = 34.5


def test_sweep_time():
with expected_protocol(HP8116A, init_comm + [("SWT 5 S", None)]) as inst:
with expected_protocol(HP8116AWithMockStatus, init_comm + [("SWT 5 S", None)]) as inst:
# This test tests also the generate_1_2_5_sequence method and truncation.
inst.sweep_time = 3


def test_limit_enabled():
with expected_protocol(HP8116A, init_comm + [("L1", None)]) as inst:
with expected_protocol(HP8116AWithMockStatus, init_comm + [("L1", None)]) as inst:
inst.limit_enabled = True

0 comments on commit a4f076a

Please sign in to comment.