diff options
Diffstat (limited to 'pylint/testutils/unittest_linter.py')
-rw-r--r-- | pylint/testutils/unittest_linter.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pylint/testutils/unittest_linter.py b/pylint/testutils/unittest_linter.py new file mode 100644 index 000000000..540874611 --- /dev/null +++ b/pylint/testutils/unittest_linter.py @@ -0,0 +1,40 @@ +# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# For details: https://github.com/PyCQA/pylint/blob/master/COPYING + +from pylint.testutils.global_test_linter import linter +from pylint.testutils.output_line import Message + + +class UnittestLinter: + """A fake linter class to capture checker messages.""" + + # pylint: disable=unused-argument, no-self-use + + def __init__(self): + self._messages = [] + self.stats = {} + + def release_messages(self): + try: + return self._messages + finally: + self._messages = [] + + def add_message( + self, msg_id, line=None, node=None, args=None, confidence=None, col_offset=None + ): + # Do not test col_offset for now since changing Message breaks everything + self._messages.append(Message(msg_id, line, node, args, confidence)) + + @staticmethod + def is_message_enabled(*unused_args, **unused_kwargs): + return True + + def add_stats(self, **kwargs): + for name, value in kwargs.items(): + self.stats[name] = value + return self.stats + + @property + def options_providers(self): + return linter.options_providers |