未验证 提交 30630454 编写于 作者: C Cleber Rosa

Merge remote-tracking branch 'ldoktor/xunit-float'

Signed-off-by: NCleber Rosa <crosa@redhat.com>
......@@ -71,12 +71,12 @@ class XUnitResult(Result):
if log_size < max_log_size:
text_output = logfile_obj.read()
else:
size = max_log_size / 2
size = int(max_log_size / 2)
logfile_obj.seek(0, 0)
text_output = logfile_obj.read(size)
text_output += ("\n\n--[ CUT DUE TO XML PER TEST "
"LIMIT ]--\n\n")
logfile_obj.seek(-size / 2, 2)
logfile_obj.seek(log_size - size, 0)
text_output += logfile_obj.read()
else:
text_output = logfile_obj.read()
......
......@@ -97,6 +97,7 @@ class xUnitSucceedTest(unittest.TestCase):
def test_max_test_log_size(self):
log = tempfile.NamedTemporaryFile(dir=self.tmpdir, delete=False)
log_content = b"1234567890" * 100
log_content += b"this should not be present" + b"0987654321" * 100
log.write(log_content)
log_path = log.name
log.close()
......@@ -117,6 +118,14 @@ class xUnitSucceedTest(unittest.TestCase):
"Length of xunit limitted to 10 chars was greater "
"than (unlimited - 500). Unlimited output:\n%s\n\n"
"Limited output:\n%s" % (unlimited, limited))
self.assertIn(b"this should not be present", unlimited)
self.assertNotIn(b"this should not be present", limited)
self.assertIn(b"1234567890", unlimited)
self.assertNotIn(b"1234567890", limited)
self.assertIn(b"12345", limited)
self.assertIn(b"0987654321", unlimited)
self.assertNotIn(b"0987654321", limited)
self.assertIn(b"54321", limited)
if __name__ == '__main__':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册