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


Python Devices.from_name方法代码示例

本文整理汇总了Python中pyudev.Devices.from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Devices.from_name方法的具体用法?Python Devices.from_name怎么用?Python Devices.from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyudev.Devices的用法示例。


在下文中一共展示了Devices.from_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_name_nonexisting_subsystem

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_name [as 别名]
 def test_from_name_nonexisting_subsystem(self, a_context):
     with pytest.raises(DeviceNotFoundByNameError) as exc_info:
         Devices.from_name(a_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)
开发者ID:cjmayo,项目名称:pyudev,代码行数:10,代码来源:_devices_tests.py

示例2: test_from_name_is_path

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_name [as 别名]
        def test_from_name_is_path(self, a_context, a_device):
            """
            Lookup using a sys_name which is actually a path should always fail.

            See: rhbz#1263351.
            """
            with pytest.raises(DeviceNotFoundByNameError):
                Devices.from_name(a_context, a_device.subsystem, a_device.sys_name)
开发者ID:dwlehman,项目名称:pyudev,代码行数:10,代码来源:_devices_tests.py

示例3: test_from_journal_name

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_name [as 别名]
 def test_from_journal_name(self, a_context, entry):
     """
     Test that kernel subsystem combined with udev sysname yields
     a device.
     """
     udev_sysname = entry['_UDEV_SYSNAME']
     subsystem = entry['_KERNEL_SUBSYSTEM']
     device = Devices.from_name(a_context, subsystem, udev_sysname)
     assert device is not None
开发者ID:dwlehman,项目名称:pyudev,代码行数:11,代码来源:_devices_tests.py

示例4: test_from_name

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_name [as 别名]
 def test_from_name(self, a_context, a_device):
     """
     Test that getting a new device based on the name and subsystem
     yields an equivalent device.
     """
     new_device = Devices.from_name(
        a_context,
        a_device.subsystem,
        a_device.sys_name
     )
     assert new_device == a_device
开发者ID:cjmayo,项目名称:pyudev,代码行数:13,代码来源:_devices_tests.py


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