1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
from typing import Any, Optional
from astroid import nodes
from pylint.interfaces import Confidence
from pylint.testutils.global_test_linter import linter
from pylint.testutils.output_line import MessageTest
from pylint.utils import LinterStats
class UnittestLinter:
"""A fake linter class to capture checker messages."""
# pylint: disable=unused-argument, no-self-use
def __init__(self):
self._messages = []
self.stats = LinterStats()
def release_messages(self):
try:
return self._messages
finally:
self._messages = []
def add_message(
self,
msg_id: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Any = None,
confidence: Optional[Confidence] = None,
col_offset: Optional[int] = None,
) -> None:
# Do not test col_offset for now since changing Message breaks everything
self._messages.append(MessageTest(msg_id, line, node, args, confidence))
@staticmethod
def is_message_enabled(*unused_args, **unused_kwargs):
return True
@property
def options_providers(self):
return linter.options_providers
|