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


Python Monitor.from_socket方法代码示例

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


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

示例1: test_from_socket_mock

# 需要导入模块: from pyudev import Monitor [as 别名]
# 或者: from pyudev.Monitor import from_socket [as 别名]
 def test_from_socket_mock(self, context, socket_path):
     socket_path = str(socket_path)
     new_from_socket = 'udev_monitor_new_from_socket'
     with pytest.patch_libudev(new_from_socket) as new_from_socket:
         new_from_socket.return_value = mock.sentinel.pointer
         monitor = Monitor.from_socket(context, socket_path)
         new_from_socket.assert_called_with(
             context, socket_path.encode(sys.getfilesystemencoding()))
         assert monitor._as_parameter_ is mock.sentinel.pointer
         Monitor.from_socket(context, 'foobar')
         new_from_socket.assert_called_with(context, b'foobar')
         assert isinstance(new_from_socket.call_args[0][1], bytes)
开发者ID:lanstat,项目名称:pyudev,代码行数:14,代码来源:test_monitor.py

示例2: test_enable_receiving_bound_socket

# 需要导入模块: from pyudev import Monitor [as 别名]
# 或者: from pyudev.Monitor import from_socket [as 别名]
 def test_enable_receiving_bound_socket(self, context, socket_path):
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
     # cause an error by binding the socket, thus testing error handling in
     # this method
     sock.bind(str(socket_path))
     monitor = Monitor.from_socket(context, str(socket_path))
     with pytest.raises(EnvironmentError) as exc_info:
         monitor.enable_receiving()
     pytest.assert_env_error(exc_info.value, errno.EADDRINUSE, str(socket_path))
开发者ID:lanstat,项目名称:pyudev,代码行数:11,代码来源:test_monitor.py

示例3: test_from_socket

# 需要导入模块: from pyudev import Monitor [as 别名]
# 或者: from pyudev.Monitor import from_socket [as 别名]
 def test_from_socket(self, context, socket_path):
     monitor = Monitor.from_socket(context, str(socket_path))
     assert monitor._as_parameter_
开发者ID:lanstat,项目名称:pyudev,代码行数:5,代码来源:test_monitor.py

示例4: test_enable_receiving_socket

# 需要导入模块: from pyudev import Monitor [as 别名]
# 或者: from pyudev.Monitor import from_socket [as 别名]
 def test_enable_receiving_socket(self, context, socket_path):
     monitor = Monitor.from_socket(context, str(socket_path))
     monitor.enable_receiving()
开发者ID:lanstat,项目名称:pyudev,代码行数:5,代码来源:test_monitor.py


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