Fix failing tests

This commit is contained in:
Jan Käberich 2024-04-20 15:57:16 +02:00
parent 2963e8b3d5
commit a202a10507
4 changed files with 18 additions and 11 deletions

View file

@ -6,12 +6,13 @@ class libreCAL:
def __init__(self, serialnum = ''):
self.ser = None
for p in serial.tools.list_ports.comports():
if p.vid == 0x0483 and p.pid == 0x4122:
if (p.vid == 0x0483 and p.pid == 0x4122) or (p.vid == 0x1209 and p.pid == 0x4122):
self.ser = serial.Serial(p.device, timeout = 1)
idn = self.SCPICommand("*IDN?").split("_")
idn = self.SCPICommand("*IDN?").split(",")
if idn[0] != "LibreCAL":
self.ser = None
continue
self.serial = idn[1]
self.serial = idn[2]
if len(serialnum) > 0:
# serial number specified, compare
if self.serial != serialnum:
@ -70,7 +71,13 @@ class libreCAL:
def getHeaterPower(self):
return float(self.SCPICommand(":HEAT:POW?"))
def getDateTimeUTC(self):
return self.SCPICommand(":DATE_TIME?")
def setDateTimeUTC(self, date_time_utc):
return self.SCPICommand(":DATE_TIME "+ date_time_utc)
def SCPICommand(self, cmd: str) -> str:
self.ser.write((cmd+"\r\n").encode())
resp = self.ser.readline().decode("ascii")
@ -78,4 +85,4 @@ class libreCAL:
raise Exception("Timeout occurred in communication with LibreCAL")
if resp.strip() == "ERROR":
raise Exception("LibreCAL returned 'ERROR' for command '"+cmd+"'")
return resp.strip()
return resp.strip()

View file

@ -32,6 +32,8 @@ class TestBase(unittest.TestCase):
if self.vna.query(":DEV:CONN?") == "Not connected":
self.tearDown()
raise AssertionError("Not connected")
# Tests occasionally fail without this timeout - give GUI a little bit more time to properly start
time.sleep(1)
def tearDown(self):
self.gui.send_signal(SIGINT)

View file

@ -8,7 +8,7 @@ class TestCalibration(TestBase):
self.vna.cmd(":VNA:CAL:MEAS "+str(number))
# wait for the measurement to finish
assert self.vna.query(":VNA:CAL:BUSY?") == "TRUE"
self.vna.cmd("*WAI")
self.vna.cmd("*WAI", timeout=timeout)
assert self.vna.query(":VNA:CAL:BUSY?") == "FALSE"
def test_dummy_calibration(self):
@ -152,9 +152,9 @@ class TestCalibration(TestBase):
# Start measurement and grab data
self.vna.cmd(":VNA:ACQ:SINGLE TRUE")
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?") == "FALSE")
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "FALSE")
self.vna.cmd("*WAI")
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?") == "TRUE")
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "TRUE")
cal.reset()

View file

@ -1,5 +1,6 @@
import re
from tests.TestBase import TestBase
import time
float_re = re.compile(r'^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]\d+)?$')
int_re = re.compile(r'^\d+$')
@ -240,7 +241,4 @@ class TestRST(TestBase):
self.vna.cmd("*RST")
settings2 = self.query_settings()
for key, value in settings1.items():
# TODO-check: *RST does not reset this parameter.
if key == "DEV:REF:OUT":
continue
self.assertEqual(value, settings2[key])