def test_from_name_nonexisting_subsystem(self, context): with pytest.raises(DeviceNotFoundByNameError) as exc_info: Device.from_name(context, "no_such_subsystem", "foobar") error = exc_info.value assert error.subsystem == "no_such_subsystem" assert error.sys_name == "foobar" assert str(error) == "No device {0!r} in {1!r}".format(error.sys_name, error.subsystem)
def test_from_name_no_device_in_existing_subsystem(self, context): with pytest.raises(DeviceNotFoundByNameError) as exc_info: Device.from_name(context, 'block', 'foobar') error = exc_info.value assert error.subsystem == 'block' assert error.sys_name == 'foobar' assert str(error) == 'No device {0!r} in {1!r}'.format( error.sys_name, error.subsystem)
def test_from_name_nonexisting_subsystem(self, context): with pytest.raises(DeviceNotFoundByNameError) as exc_info: Device.from_name(context, 'no_such_subsystem', 'foobar') error = exc_info.value assert error.subsystem == 'no_such_subsystem' assert error.sys_name == 'foobar' assert str(error) == 'No device {0!r} in {1!r}'.format( error.sys_name, error.subsystem)
def test_from_name(self, context, device): new_device = Device.from_name(context, device.subsystem, device.sys_name) assert new_device == device