本文整理汇总了Python中pyudev.Devices.from_device_file方法的典型用法代码示例。如果您正苦于以下问题:Python Devices.from_device_file方法的具体用法?Python Devices.from_device_file怎么用?Python Devices.from_device_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyudev.Devices
的用法示例。
在下文中一共展示了Devices.from_device_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_device_file_no_device_file
# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_file [as 别名]
def test_from_device_file_no_device_file(self, tmpdir, a_context):
filename = tmpdir.join('test')
filename.ensure(file=True)
with pytest.raises(DeviceNotFoundByFileError) as excinfo:
Devices.from_device_file(a_context, str(filename))
message = 'not a device file: {0!r}'.format(str(filename))
assert str(excinfo.value) == message
示例2: test_from_device_file_non_existing
# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_file [as 别名]
def test_from_device_file_non_existing(self, tmpdir, a_context):
"""
Test that an OSError is raised when constructing a ``Device`` from
a file that does not actually exist.
"""
filename = tmpdir.join('test_from_device_file_non_existing')
assert not tmpdir.check(file=True)
with pytest.raises(DeviceNotFoundByFileError):
Devices.from_device_file(a_context, str(filename))
示例3: test_from_device_file
# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_file [as 别名]
def test_from_device_file(self, a_context, device_datum):
device = Devices.from_device_file(
a_context,
device_datum.device_node
)
assert device.device_node == device_datum.device_node
assert device.device_path == device_datum.device_path
示例4: test_from_device_file_links
# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_file [as 别名]
def test_from_device_file_links(self, a_context, device_datum):
"""
For each link in DEVLINKS, test that the constructed device's
path matches the orginal devices path.
This does not hold true in the case of multipath. In this case
udevadm's DEVLINKS fields holds some links that do not actually
point to the originating device.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1263441.
"""
device = Devices.from_path(a_context, device_datum.device_path)
assume(not 'DM_MULTIPATH_TIMESTAMP' in device)
for link in device_datum.device_links:
link = os.path.join(a_context.device_path, link)
device = Devices.from_device_file(a_context, link)
assert device.device_path == device_datum.device_path
assert link in device.device_links