def test_from_sys_path_device_not_found(self, a_context): sys_path = 'there_will_not_be_such_a_device' with pytest.raises(DeviceNotFoundAtPathError) as exc_info: Devices.from_sys_path(a_context, sys_path) error = exc_info.value assert error.sys_path == sys_path assert str(error) == 'No device at {0!r}'.format(sys_path)
def test_from_sys_path_device_not_found(self): """ Verify that a non-existant sys_path causes an exception. """ sys_path = 'there_will_not_be_such_a_device' with pytest.raises(DeviceNotFoundAtPathError) as exc_info: Devices.from_sys_path(_CONTEXT, sys_path) error = exc_info.value assert error.sys_path == sys_path
def get_inputdev_info(device): if device.action != 'add' or device.device_node == None or device.sys_name == None: return None d = Devices.from_sys_path( device.context, device.sys_path[:device.sys_path.rfind(device.sys_name)]) try: return (d.sys_path, d.attributes.asstring('name').upper(), device.device_node) except: return None
def test_from_sys_path(self, a_context, device_datum): device = Devices.from_sys_path(a_context, device_datum.sys_path) assert device is not None assert device.sys_path == device_datum.sys_path
def test_from_sys_path(self, a_context, a_device): """ from_sys_path() yields the correct device. """ assert a_device == Devices.from_sys_path(a_context, a_device.sys_path)