speed up tests

This commit is contained in:
Jan Käberich 2024-12-17 12:06:55 +01:00
parent 70ac53aa75
commit a2abc0c2af
2 changed files with 7 additions and 10 deletions

View file

@ -14,15 +14,16 @@ class TestBase(unittest.TestCase):
timeout = time.time() + 3;
poll_obj = select.poll()
poll_obj.register(self.gui.stdout, select.POLLIN)
while time.time() < timeout:
while True:
poll_result = poll_obj.poll(0)
if poll_result:
line = self.gui.stdout.readline().decode().strip()
if "Listening on port 19544" in line:
break
time.sleep(1)
if time.time() >= timeout:
self.tearDown()
raise AssertionError("Timed out waiting for SCPI server")
self.vna = libreVNA('localhost', 19544, timeout=4)
try:
self.vna.cmd("*CLS;:DEV:CONN")
@ -34,6 +35,8 @@ class TestBase(unittest.TestCase):
raise AssertionError("Not connected")
def tearDown(self):
# make sure the GUI did not crash during the test
self.assertEqual(self.gui.poll(), None)
self.gui.send_signal(SIGINT)
try:
self.gui.wait(timeout = 3)

View file

@ -236,16 +236,10 @@ class TestRST(TestBase):
self.vna.cmd(f"VNA:STIM:FREQ {f_1_3}")
self.vna.cmd(f"VNA:STIM:LVL {pwr_min}")
self.vna.cmd("VNA:SWEEP POWER")
# We just configured a lot of settings, give some time to empty the output queue from the GUI to the device
time.sleep(2)
# Reset and verify all settings revert.
self.vna.cmd("*RST")
# ... and wait a little bit here again to let the changes from the RST propagate from the device and back to the GUI (otherwise we might still read wrong external reference settings for example)
time.sleep(2)
settings2 = self.query_settings()
for key, value in settings1.items():
self.assertEqual(value, settings2[key])