diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-16 09:00:18 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-28 22:45:45 +0200 |
commit | c8c3aaf68dde68b8d5154c3b0acdc2f789afda64 (patch) | |
tree | 4e9e6bfc9ef04cd04cdf6cc6ef25685223af00c2 | |
parent | fb74bd666cd2cf0eb5fddd47c6855f79f2c2ab8f (diff) | |
download | pylint-git-c8c3aaf68dde68b8d5154c3b0acdc2f789afda64.tar.gz |
Change the order of the assert for better pytest message
-rw-r--r-- | pylint/testutils/checker_test_case.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pylint/testutils/checker_test_case.py b/pylint/testutils/checker_test_case.py index 1d029687f..d6846e18f 100644 --- a/pylint/testutils/checker_test_case.py +++ b/pylint/testutils/checker_test_case.py @@ -38,11 +38,14 @@ class CheckerTestCase: """ yield got = self.linter.release_messages() - msg = "Expected messages did not match actual.\n" "Expected:\n%s\nGot:\n%s" % ( - "\n".join(repr(m) for m in messages), - "\n".join(repr(m) for m in got), + no_msg = "No message." + expected = "\n".join(repr(m) for m in messages) or no_msg + got_str = "\n".join(repr(m) for m in got) or no_msg + msg = ( + "Expected messages did not match actual.\n" + f"\nExpected:\n{expected}\n\nGot:\n{got_str}\n" ) - assert list(messages) == got, msg + assert got == list(messages), msg def walk(self, node): """recursive walk on the given node""" |