Skip to content

Commit

Permalink
Relax lint message string comparison
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davelopez committed Sep 13, 2023
1 parent 7b8c176 commit c96b9a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/galaxy/tool_util/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions test/unit/tool_util/test_tool_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<unknown>, 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
Expand Down

0 comments on commit c96b9a4

Please sign in to comment.