forked from M-Labs/artiq
test: add test for exception on non-existent I2C bus
This commit is contained in:
parent
d08bd58dff
commit
09d198c7a1
@ -2,6 +2,8 @@ import os, unittest
|
||||
|
||||
from artiq.experiment import *
|
||||
from artiq.test.hardware_testbench import ExperimentCase
|
||||
from artiq.coredevice.exceptions import I2CError
|
||||
from artiq.coredevice.i2c import PCA9548
|
||||
|
||||
|
||||
class I2CSwitch(EnvExperiment):
|
||||
@ -19,7 +21,21 @@ class I2CSwitch(EnvExperiment):
|
||||
self.set_dataset("passed", passed)
|
||||
|
||||
|
||||
class NonexistentI2CBus(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.broken_switch = PCA9548(self._HasEnvironment__device_mgr, 255)
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.broken_switch.set(0)
|
||||
|
||||
|
||||
class I2CTest(ExperimentCase):
|
||||
def test_i2c_switch(self):
|
||||
self.execute(I2CSwitch)
|
||||
self.assertTrue(self.dataset_mgr.get("passed"))
|
||||
|
||||
def test_nonexistent_bus(self):
|
||||
with self.assertRaises(I2CError):
|
||||
self.execute(NonexistentI2CBus)
|
||||
|
Loading…
Reference in New Issue
Block a user