diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2018-11-10 09:45:27 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-12-18 07:49:48 +0100 |
commit | 572f35f92e9eeffd7f6e48b6de1e3623848a39cc (patch) | |
tree | 453149c4090811a31f8fa86cac770e816f8b6858 | |
parent | bce332ab43b6d7cce30bc833d2d3d1e1cd6f1054 (diff) | |
download | pylint-git-572f35f92e9eeffd7f6e48b6de1e3623848a39cc.tar.gz |
Refactor - Made the error message predictable
When refactoring MsgStore we don't want the test to break if two
conflicting symbol or msgid are inverted. So we sort them, in order
for the error message to stay stable.
-rw-r--r-- | pylint/test/unittest_utils.py | 2 | ||||
-rw-r--r-- | pylint/utils.py | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/pylint/test/unittest_utils.py b/pylint/test/unittest_utils.py index b1cefead5..f295d9354 100644 --- a/pylint/test/unittest_utils.py +++ b/pylint/test/unittest_utils.py @@ -123,7 +123,7 @@ def store(): ), "W1234": ("message one", "msg-symbol-one", "msg description"), }, - "Message id 'W1234' cannot have both 'old-symbol' and 'msg-symbol-one' as symbolic name.", + "Message id 'W1234' cannot have both 'msg-symbol-one' and 'old-symbol' as symbolic name.", ), ( { diff --git a/pylint/utils.py b/pylint/utils.py index 9119d1713..506dbf0ca 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -973,9 +973,11 @@ class MessagesStore: :param str other_symbol: Other offending symbol :raises InvalidMessageError: when a symbol is duplicated. """ + symbols = [symbol, other_symbol] + symbols.sort() error_message = "Message id '{msgid}' cannot have both ".format(msgid=msgid) error_message += "'{other_symbol}' and '{symbol}' as symbolic name.".format( - other_symbol=other_symbol, symbol=symbol + other_symbol=symbols[0], symbol=symbols[1] ) raise InvalidMessageError(error_message) @@ -988,11 +990,13 @@ class MessagesStore: :param str other_msgid: Other offending msgid :raises InvalidMessageError: when a msgid is duplicated. """ + msgids = [msgid, other_msgid] + msgids.sort() error_message = "Message symbol '{symbol}' cannot be used for ".format( symbol=symbol ) error_message += "'{other_msgid}' and '{msgid}' at the same time.".format( - other_msgid=other_msgid, msgid=msgid + other_msgid=msgids[0], msgid=msgids[1] ) raise InvalidMessageError(error_message) |