当前位置: 首页>>代码示例>>Python>>正文


Python Devices.from_device_file方法代码示例

本文整理汇总了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
开发者ID:cjmayo,项目名称:pyudev,代码行数:9,代码来源:_devices_tests.py

示例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))
开发者ID:cjmayo,项目名称:pyudev,代码行数:11,代码来源:_devices_tests.py

示例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
开发者ID:cjmayo,项目名称:pyudev,代码行数:9,代码来源:_devices_tests.py

示例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
开发者ID:cjmayo,项目名称:pyudev,代码行数:22,代码来源:_devices_tests.py


注:本文中的pyudev.Devices.from_device_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。