From d9433b743cad0ce61811c58096b917f720ef15e7 Mon Sep 17 00:00:00 2001 From: Adam Debek Date: Thu, 28 Nov 2024 14:49:27 +0100 Subject: [PATCH] trunner: add formatting to subresult message with newlines JIRA: CI-519 --- trunner/types.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/trunner/types.py b/trunner/types.py index 469109e8a..494d326ab 100644 --- a/trunner/types.py +++ b/trunner/types.py @@ -345,9 +345,18 @@ def __str__(self) -> str: out = f"\t{bold(self.subname)}: {self.status}" if self.msg and self.status != Status.OK: - out += ": " + self.msg - - return out + shift_length = len(f"{self.subname}: {self.status.name}: ") + first_line, *remaining_lines = self.msg.splitlines() + # Make msg with newlines aligned + if remaining_lines: + remaining_lines = "\n" + "\n".join( + f'\t{" " * shift_length}{line.lstrip()}' + for line in remaining_lines + ) + else: + remaining_lines = "" + + out += ": " + first_line + remaining_lines def _init_subresult(self): # subresults can't contain subresults