Skip to content

Commit 54c4e1d

Browse files
Create a file for the global test linter
1 parent fa8f15d commit 54c4e1d

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2+
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
3+
4+
5+
from pylint import checkers
6+
from pylint.lint import PyLinter
7+
from pylint.testutils.reporter_for_tests import GenericTestReporter
8+
9+
10+
def create_test_linter():
11+
test_reporter = GenericTestReporter()
12+
linter_ = PyLinter()
13+
linter_.set_reporter(test_reporter)
14+
linter_.config.persistent = 0
15+
checkers.initialize(linter_)
16+
return linter_
17+
18+
19+
# Can't be renamed to a constant (easily), it breaks countless tests
20+
linter = create_test_linter()

pylint/testutils/utils.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
from io import StringIO
1010
from os.path import basename, join, splitext
1111

12-
from pylint import checkers
13-
from pylint.lint import PyLinter
1412
from pylint.testutils.constants import SYS_VERS_STR
13+
from pylint.testutils.global_test_linter import linter
1514
from pylint.testutils.output_line import Message
16-
from pylint.testutils.reporter_for_tests import GenericTestReporter
1715
from pylint.utils import ASTWalker
1816

1917

@@ -150,13 +148,5 @@ def walk(self, node):
150148
walker.walk(node)
151149

152150

153-
# Init
154-
test_reporter = GenericTestReporter()
155-
linter = PyLinter()
156-
linter.set_reporter(test_reporter)
157-
linter.config.persistent = 0
158-
checkers.initialize(linter)
159-
160-
161151
def _tokenize_str(code):
162152
return list(tokenize.generate_tokens(StringIO(code).readline))

0 commit comments

Comments
 (0)