mirror of
https://github.com/jankae/LibreVNA.git
synced 2025-12-06 07:12:10 +01:00
Fix failing tests
This commit is contained in:
parent
2963e8b3d5
commit
a202a10507
|
|
@ -6,12 +6,13 @@ class libreCAL:
|
||||||
def __init__(self, serialnum = ''):
|
def __init__(self, serialnum = ''):
|
||||||
self.ser = None
|
self.ser = None
|
||||||
for p in serial.tools.list_ports.comports():
|
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)
|
self.ser = serial.Serial(p.device, timeout = 1)
|
||||||
idn = self.SCPICommand("*IDN?").split("_")
|
idn = self.SCPICommand("*IDN?").split(",")
|
||||||
if idn[0] != "LibreCAL":
|
if idn[0] != "LibreCAL":
|
||||||
|
self.ser = None
|
||||||
continue
|
continue
|
||||||
self.serial = idn[1]
|
self.serial = idn[2]
|
||||||
if len(serialnum) > 0:
|
if len(serialnum) > 0:
|
||||||
# serial number specified, compare
|
# serial number specified, compare
|
||||||
if self.serial != serialnum:
|
if self.serial != serialnum:
|
||||||
|
|
@ -71,6 +72,12 @@ class libreCAL:
|
||||||
def getHeaterPower(self):
|
def getHeaterPower(self):
|
||||||
return float(self.SCPICommand(":HEAT:POW?"))
|
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:
|
def SCPICommand(self, cmd: str) -> str:
|
||||||
self.ser.write((cmd+"\r\n").encode())
|
self.ser.write((cmd+"\r\n").encode())
|
||||||
resp = self.ser.readline().decode("ascii")
|
resp = self.ser.readline().decode("ascii")
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ class TestBase(unittest.TestCase):
|
||||||
if self.vna.query(":DEV:CONN?") == "Not connected":
|
if self.vna.query(":DEV:CONN?") == "Not connected":
|
||||||
self.tearDown()
|
self.tearDown()
|
||||||
raise AssertionError("Not connected")
|
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):
|
def tearDown(self):
|
||||||
self.gui.send_signal(SIGINT)
|
self.gui.send_signal(SIGINT)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class TestCalibration(TestBase):
|
||||||
self.vna.cmd(":VNA:CAL:MEAS "+str(number))
|
self.vna.cmd(":VNA:CAL:MEAS "+str(number))
|
||||||
# wait for the measurement to finish
|
# wait for the measurement to finish
|
||||||
assert self.vna.query(":VNA:CAL:BUSY?") == "TRUE"
|
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"
|
assert self.vna.query(":VNA:CAL:BUSY?") == "FALSE"
|
||||||
|
|
||||||
def test_dummy_calibration(self):
|
def test_dummy_calibration(self):
|
||||||
|
|
@ -152,9 +152,9 @@ class TestCalibration(TestBase):
|
||||||
|
|
||||||
# Start measurement and grab data
|
# Start measurement and grab data
|
||||||
self.vna.cmd(":VNA:ACQ:SINGLE TRUE")
|
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.vna.cmd("*WAI")
|
||||||
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?") == "TRUE")
|
self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "TRUE")
|
||||||
|
|
||||||
cal.reset()
|
cal.reset()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
from tests.TestBase import TestBase
|
from tests.TestBase import TestBase
|
||||||
|
import time
|
||||||
|
|
||||||
float_re = re.compile(r'^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]\d+)?$')
|
float_re = re.compile(r'^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]\d+)?$')
|
||||||
int_re = re.compile(r'^\d+$')
|
int_re = re.compile(r'^\d+$')
|
||||||
|
|
@ -240,7 +241,4 @@ class TestRST(TestBase):
|
||||||
self.vna.cmd("*RST")
|
self.vna.cmd("*RST")
|
||||||
settings2 = self.query_settings()
|
settings2 = self.query_settings()
|
||||||
for key, value in settings1.items():
|
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])
|
self.assertEqual(value, settings2[key])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue