test: fix handling of missing devices

This commit is contained in:
Sebastien Bourdeauducq 2018-08-09 16:51:12 +08:00
parent a061ba2505
commit bf78e0c7d2
2 changed files with 17 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import unittest
import asyncio import asyncio
from artiq.coredevice.comm_moninj import * from artiq.coredevice.comm_moninj import *
@ -6,9 +7,17 @@ from artiq.test.hardware_testbench import ExperimentCase
class MonInjTest(ExperimentCase): class MonInjTest(ExperimentCase):
def test_moninj(self): def test_moninj(self):
core_host = self.device_mgr.get_desc("core")["arguments"]["host"] try:
loop_out_channel = self.device_mgr.get_desc("loop_out")["arguments"]["channel"] core = self.device_mgr.get_desc("core")
loop_in_channel = self.device_mgr.get_desc("loop_in")["arguments"]["channel"] loop_out = self.device_mgr.get_desc("loop_out")
loop_in = self.device_mgr.get_desc("loop_in")
except KeyError as e:
# skip if ddb does not match requirements
raise unittest.SkipTest(
"test device not available: `{}`".format(*e.args))
core_host = core["arguments"]["host"]
loop_out_channel = loop_out["arguments"]["channel"]
loop_in_channel = loop_in["arguments"]["channel"]
notifications = [] notifications = []
injection_statuses = [] injection_statuses = []

View File

@ -11,7 +11,7 @@ import time
import socket import socket
from artiq.master.databases import DeviceDB, DatasetDB from artiq.master.databases import DeviceDB, DatasetDB
from artiq.master.worker_db import DeviceManager, DatasetManager from artiq.master.worker_db import DeviceManager, DatasetManager, DeviceError
from artiq.coredevice.core import CompileError from artiq.coredevice.core import CompileError
from artiq.frontend.artiq_run import DummyScheduler from artiq.frontend.artiq_run import DummyScheduler
from artiq.protocols.pc_rpc import AutoTarget, Client from artiq.protocols.pc_rpc import AutoTarget, Client
@ -113,12 +113,12 @@ class ExperimentCase(unittest.TestCase):
exp = cls( exp = cls(
(self.device_mgr, self.dataset_mgr, None), (self.device_mgr, self.dataset_mgr, None),
*args, **kwargs) *args, **kwargs)
exp.prepare() except DeviceError as e:
return exp
except KeyError as e:
# skip if ddb does not match requirements # skip if ddb does not match requirements
raise unittest.SkipTest( raise unittest.SkipTest(
"device_db entry `{}` not found".format(*e.args)) "test device not available: `{}`".format(*e.args))
exp.prepare()
return exp
def execute(self, cls, *args, **kwargs): def execute(self, cls, *args, **kwargs):
expid = { expid = {