本文整理汇总了Python中pyudev.Device.from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Device.from_name方法的具体用法?Python Device.from_name怎么用?Python Device.from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyudev.Device
的用法示例。
在下文中一共展示了Device.from_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_name_nonexisting_subsystem
# 需要导入模块: from pyudev import Device [as 别名]
# 或者: from pyudev.Device import from_name [as 别名]
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)
示例2: test_from_name_no_device_in_existing_subsystem
# 需要导入模块: from pyudev import Device [as 别名]
# 或者: from pyudev.Device import from_name [as 别名]
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)
示例3: test_from_name
# 需要导入模块: from pyudev import Device [as 别名]
# 或者: from pyudev.Device import from_name [as 别名]
def test_from_name(self, context, device):
new_device = Device.from_name(context, device.subsystem, device.sys_name)
assert new_device == device