本文整理汇总了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)
示例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))
示例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_
示例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()