本文整理汇总了Python中kmip.services.kmip_client.KMIPProxy.socket方法的典型用法代码示例。如果您正苦于以下问题:Python KMIPProxy.socket方法的具体用法?Python KMIPProxy.socket怎么用?Python KMIPProxy.socket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmip.services.kmip_client.KMIPProxy
的用法示例。
在下文中一共展示了KMIPProxy.socket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close
# 需要导入模块: from kmip.services.kmip_client import KMIPProxy [as 别名]
# 或者: from kmip.services.kmip_client.KMIPProxy import socket [as 别名]
def test_close(self):
"""
Test that calling close on the client works as expected.
"""
c = KMIPProxy(
host="IP_ADDR_1, IP_ADDR_2",
port=9090,
ca_certs=None
)
c.socket = mock.MagicMock()
c_socket = c.socket
c.socket.shutdown.assert_not_called()
c.socket.close.assert_not_called()
c.close()
self.assertEqual(None, c.socket)
c_socket.shutdown.assert_called_once_with(socket.SHUT_RDWR)
c_socket.close.assert_called_once()
示例2: test_close_with_shutdown_error
# 需要导入模块: from kmip.services.kmip_client import KMIPProxy [as 别名]
# 或者: from kmip.services.kmip_client.KMIPProxy import socket [as 别名]
def test_close_with_shutdown_error(self):
"""
Test that calling close on an unconnected client does not trigger an
exception.
"""
c = KMIPProxy(
host="IP_ADDR_1, IP_ADDR_2",
port=9090,
ca_certs=None
)
c.socket = mock.MagicMock()
c_socket = c.socket
c.socket.shutdown.side_effect = OSError
c.socket.shutdown.assert_not_called()
c.socket.close.assert_not_called()
c.close()
self.assertEqual(None, c.socket)
c_socket.shutdown.assert_called_once_with(socket.SHUT_RDWR)
c_socket.close.assert_not_called()