From c96b9a4efc0fa5e4fc44f91490672ea0740e3636 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:20:39 +0200 Subject: [PATCH] Relax lint message string comparison This will allow to check that certain reasonable parts of the message are present without expecting an exact match. This is useful, when the warning or error messages slightly differ from version to version. --- lib/galaxy/tool_util/lint.py | 7 +++++-- test/unit/tool_util/test_tool_linters.py | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/tool_util/lint.py b/lib/galaxy/tool_util/lint.py index 60fe25c03667..44ab28b9790e 100644 --- a/lib/galaxy/tool_util/lint.py +++ b/lib/galaxy/tool_util/lint.py @@ -83,10 +83,13 @@ def __init__(self, level: str, message: str, **kwargs): def __eq__(self, other) -> bool: """ add equal operator to easy lookup of a message in a - List[LintMessage] which is usefull in tests + List[LintMessage] which is useful in tests. + + If the other object is a string, it is loosely checked if the + string is contained in the message. """ if isinstance(other, str): - return self.message == other + return other in self.message if isinstance(other, LintMessage): return self.message == other.message return False diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index eea3ac643475..7b2f134192a9 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -1391,10 +1391,7 @@ def test_inputs_validator_incompatibilities(lint_ctx): "Parameter [param_name]: '[' is no valid regular expression: unterminated character set at position 0" in lint_ctx.error_messages ) - assert ( - "Parameter [param_name]: '(' is no valid regular expression: unexpected EOF while parsing (, line 1)" - in lint_ctx.error_messages - ) + assert "Parameter [param_name]: '(' is no valid regular expression" in lint_ctx.error_messages assert ( "Parameter [another_param_name]: 'metadata' validators need to define the 'check' or 'skip' attribute(s)" in lint_ctx.error_messages