def test_command_output_ends_with_truncation(self):
"""After truncation, no further output is recorded."""
factory = StubProcessFactory()
self.plugin.process_factory = factory
self.plugin.size_limit = 100
result = self.plugin.run_script("/bin/sh", "")
# Ultimately we assert that the resulting output is limited to
# 100 bytes and indicates its truncation.
result.addCallback(self.assertEqual,
("x" * 79) + "\n**OUTPUT TRUNCATED**")
protocol = factory.spawns[0][0]
# Push 200 bytes of output, so we trigger truncation.
protocol.childDataReceived(1, b"x" * 200)
# Push 200 bytes more
protocol.childDataReceived(1, b"x" * 200)
for fd in (0, 1, 2):
protocol.childConnectionLost(fd)
protocol.processEnded(Failure(ProcessDone(0)))
return result
test_scriptexecution.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录