diff --git a/lib/galaxy/tool_util/lint.py b/lib/galaxy/tool_util/lint.py index 91435adfac1..8bf081e3c56 100644 --- a/lib/galaxy/tool_util/lint.py +++ b/lib/galaxy/tool_util/lint.py @@ -75,14 +75,20 @@ class LintMessage: self.xpath = xpath def __str__(self): - rval = f".. {self.level.upper()}: {self.message}" - if self.line is not None: + return f".. {self.level.upper()}: {self.message}" + + def pretty_print(self, level=True, fname=True, xpath=False): + rval = "" + if level: + rval += f".. {self.level.upper()}: " + rval += "{self.message}" + if fname and self.line is not None: rval += " (" if self.fname: rval += f"{self.fname}:" rval += str(self.line) rval += ")" - if self.xpath is not None: + if xpath and self.xpath is not None: rval += f" [{self.xpath}]" return rval diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index ba1eded35e2..d34c90ba1d5 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -1131,9 +1131,10 @@ def test_tool_xml(tool_xml, lint_func, assert_func): if first_arg != "tool_xml": lint_target = XmlToolSource(lint_target) lint_ctx.lint(name="test_lint", lint_func=lint_func, lint_target=lint_target) - # TODO would be nice if lint_general would have full context as well - if lint_func != general.lint_general: - for message in lint_ctx.message_list: + for message in lint_ctx.message_list: + message.pretty_print(level=True, fname=True, xpath=True) + # TODO would be nice if lint_general would have full context as well + if lint_func != general.lint_general: assert message.line is not None, f"No context found for message: {message.message}" assert assert_func(lint_ctx), ( f"Valid: {lint_ctx.valid_messages}\n"