本文整理匯總了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