summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2020-11-29 11:03:49 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2020-11-29 11:59:49 +0100
commit54c4e1dc404456e1dc33540a24eed8ce68b234e0 (patch)
tree57eb684da7ca3a8ec0f55729832663a4166e7e11
parentfa8f15d15c84815fee79e2504735f0b5d25c92ab (diff)
downloadpylint-git-54c4e1dc404456e1dc33540a24eed8ce68b234e0.tar.gz
Create a file for the global test linter
-rw-r--r--pylint/testutils/global_test_linter.py20
-rw-r--r--pylint/testutils/utils.py12
2 files changed, 21 insertions, 11 deletions
diff --git a/pylint/testutils/global_test_linter.py b/pylint/testutils/global_test_linter.py
new file mode 100644
index 000000000..75a55e9c0
--- /dev/null
+++ b/pylint/testutils/global_test_linter.py
@@ -0,0 +1,20 @@
+# 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 import checkers
+from pylint.lint import PyLinter
+from pylint.testutils.reporter_for_tests import GenericTestReporter
+
+
+def create_test_linter():
+ test_reporter = GenericTestReporter()
+ linter_ = PyLinter()
+ linter_.set_reporter(test_reporter)
+ linter_.config.persistent = 0
+ checkers.initialize(linter_)
+ return linter_
+
+
+# Can't be renamed to a constant (easily), it breaks countless tests
+linter = create_test_linter()
diff --git a/pylint/testutils/utils.py b/pylint/testutils/utils.py
index 653db2b7a..3576f5977 100644
--- a/pylint/testutils/utils.py
+++ b/pylint/testutils/utils.py
@@ -9,11 +9,9 @@ from glob import glob
from io import StringIO
from os.path import basename, join, splitext
-from pylint import checkers
-from pylint.lint import PyLinter
from pylint.testutils.constants import SYS_VERS_STR
+from pylint.testutils.global_test_linter import linter
from pylint.testutils.output_line import Message
-from pylint.testutils.reporter_for_tests import GenericTestReporter
from pylint.utils import ASTWalker
@@ -150,13 +148,5 @@ class CheckerTestCase:
walker.walk(node)
-# Init
-test_reporter = GenericTestReporter()
-linter = PyLinter()
-linter.set_reporter(test_reporter)
-linter.config.persistent = 0
-checkers.initialize(linter)
-
-
def _tokenize_str(code):
return list(tokenize.generate_tokens(StringIO(code).readline))