本文整理汇总了Python中pants.java.nailgun_protocol.NailgunProtocol.read_chunk方法的典型用法代码示例。如果您正苦于以下问题:Python NailgunProtocol.read_chunk方法的具体用法?Python NailgunProtocol.read_chunk怎么用?Python NailgunProtocol.read_chunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.java.nailgun_protocol.NailgunProtocol
的用法示例。
在下文中一共展示了NailgunProtocol.read_chunk方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_chunk_truncated_during_payload
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_read_chunk_truncated_during_payload(self):
"""Construct a chunk and truncate the last 3 bytes of the payload ([:-3])."""
truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:-3]
self.server_sock.sendall(truncated_chunk)
self.server_sock.close()
with self.assertRaises(NailgunProtocol.TruncatedPayloadError):
NailgunProtocol.read_chunk(self.client_sock)
示例2: test_read_chunk_truncated_before_payload
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_read_chunk_truncated_before_payload(self):
"""Construct a chunk and send exactly the header (first 5 bytes) and truncate the remainder."""
truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:5]
self.server_sock.sendall(truncated_chunk)
self.server_sock.close()
with self.assertRaises(NailgunProtocol.TruncatedPayloadError):
NailgunProtocol.read_chunk(self.client_sock)
示例3: test_read_chunk_truncated_during_header
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_read_chunk_truncated_during_header(self):
"""Construct a chunk and truncate to the first 3 bytes ([:3]), an incomplete header."""
truncated_chunk = NailgunProtocol.construct_chunk(ChunkType.STDOUT, self.TEST_OUTPUT)[:3]
self.server_sock.sendall(truncated_chunk)
self.server_sock.close()
with self.assertRaises(NailgunProtocol.TruncatedHeaderError):
NailgunProtocol.read_chunk(self.client_sock)
示例4: test_send_exit
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_exit(self):
NailgunProtocol.send_exit(self.server_sock, self.TEST_OUTPUT)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock)
self.assertEqual(
(chunk_type, payload),
(ChunkType.EXIT, self.TEST_OUTPUT)
)
示例5: test_send_exit_default
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_exit_default(self):
NailgunProtocol.send_exit(self.server_sock)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock)
self.assertEqual(
(chunk_type, payload),
(ChunkType.EXIT, self.EMPTY_PAYLOAD)
)
示例6: test_send_start_reading_input
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_start_reading_input(self):
NailgunProtocol.send_start_reading_input(self.server_sock)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock)
self.assertEqual(
(chunk_type, payload),
(ChunkType.START_READING_INPUT, self.EMPTY_PAYLOAD)
)
示例7: test_send_unicode_chunk
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_unicode_chunk(self):
NailgunProtocol.send_stdout(self.server_sock, self.TEST_UNICODE_PAYLOAD)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock, return_bytes=True)
self.assertEqual(
(chunk_type, payload),
(ChunkType.STDOUT, self.TEST_UNICODE_PAYLOAD)
)
示例8: test_send_exit_with_code
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_exit_with_code(self):
return_code = 1
NailgunProtocol.send_exit_with_code(self.server_sock, return_code)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock, return_bytes=True)
self.assertEqual(
(chunk_type, payload),
(ChunkType.EXIT, NailgunProtocol.encode_int(return_code))
)
示例9: test_send_pid
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_send_pid(self):
test_pid = 1
NailgunProtocol.send_pid(self.server_sock, test_pid)
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock, return_bytes=True)
self.assertEqual(
(chunk_type, payload),
(ChunkType.PID, NailgunProtocol.encode_int(test_pid))
)
示例10: test_read_and_write_chunk
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import read_chunk [as 别名]
def test_read_and_write_chunk(self):
# Write a command chunk to the server socket.
NailgunProtocol.write_chunk(self.server_sock, ChunkType.COMMAND, self.TEST_COMMAND)
# Read the chunk from the client socket.
chunk_type, payload = NailgunProtocol.read_chunk(self.client_sock)
self.assertEqual(
(chunk_type, payload),
(ChunkType.COMMAND, self.TEST_COMMAND)
)