summaryrefslogtreecommitdiff
path: root/pylint/testutils
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/testutils')
-rw-r--r--pylint/testutils/__init__.py4
-rw-r--r--pylint/testutils/_primer/__init__.py4
-rw-r--r--pylint/testutils/_primer/package_to_lint.py4
-rw-r--r--pylint/testutils/_primer/primer.py4
-rw-r--r--pylint/testutils/_primer/primer_command.py4
-rw-r--r--pylint/testutils/_primer/primer_compare_command.py4
-rw-r--r--pylint/testutils/_primer/primer_prepare_command.py4
-rw-r--r--pylint/testutils/_primer/primer_run_command.py10
-rw-r--r--pylint/testutils/_run.py9
-rw-r--r--pylint/testutils/checker_test_case.py24
-rw-r--r--pylint/testutils/configuration_test.py4
-rw-r--r--pylint/testutils/constants.py4
-rw-r--r--pylint/testutils/decorator.py4
-rw-r--r--pylint/testutils/functional/__init__.py4
-rw-r--r--pylint/testutils/functional/find_functional_tests.py104
-rw-r--r--pylint/testutils/functional/lint_module_output_update.py4
-rw-r--r--pylint/testutils/functional/test_file.py6
-rw-r--r--pylint/testutils/functional_test_file.py24
-rw-r--r--pylint/testutils/get_test_info.py4
-rw-r--r--pylint/testutils/global_test_linter.py4
-rw-r--r--pylint/testutils/lint_module_test.py8
-rw-r--r--pylint/testutils/output_line.py70
-rw-r--r--pylint/testutils/pyreverse.py8
-rw-r--r--pylint/testutils/reporter_for_tests.py6
-rw-r--r--pylint/testutils/testing_pylintrc4
-rw-r--r--pylint/testutils/tokenize_str.py4
-rw-r--r--pylint/testutils/unittest_linter.py4
-rw-r--r--pylint/testutils/utils.py4
28 files changed, 160 insertions, 181 deletions
diff --git a/pylint/testutils/__init__.py b/pylint/testutils/__init__.py
index e9b8de1de..0ff9b773b 100644
--- a/pylint/testutils/__init__.py
+++ b/pylint/testutils/__init__.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
"""Functional/non regression tests for pylint."""
diff --git a/pylint/testutils/_primer/__init__.py b/pylint/testutils/_primer/__init__.py
index 17c854572..2c40f561b 100644
--- a/pylint/testutils/_primer/__init__.py
+++ b/pylint/testutils/_primer/__init__.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
__all__ = ["PackageToLint", "PRIMER_DIRECTORY_PATH"]
diff --git a/pylint/testutils/_primer/package_to_lint.py b/pylint/testutils/_primer/package_to_lint.py
index d59f93ed5..11df63bd2 100644
--- a/pylint/testutils/_primer/package_to_lint.py
+++ b/pylint/testutils/_primer/package_to_lint.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/_primer/primer.py b/pylint/testutils/_primer/primer.py
index 7d08f1df5..abe6bc4dd 100644
--- a/pylint/testutils/_primer/primer.py
+++ b/pylint/testutils/_primer/primer.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/_primer/primer_command.py b/pylint/testutils/_primer/primer_command.py
index bbc930913..08adedd4c 100644
--- a/pylint/testutils/_primer/primer_command.py
+++ b/pylint/testutils/_primer/primer_command.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/_primer/primer_compare_command.py b/pylint/testutils/_primer/primer_compare_command.py
index acc1c9562..b405d7577 100644
--- a/pylint/testutils/_primer/primer_compare_command.py
+++ b/pylint/testutils/_primer/primer_compare_command.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
import json
diff --git a/pylint/testutils/_primer/primer_prepare_command.py b/pylint/testutils/_primer/primer_prepare_command.py
index e69e55b95..4cbc5cf17 100644
--- a/pylint/testutils/_primer/primer_prepare_command.py
+++ b/pylint/testutils/_primer/primer_prepare_command.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
import sys
diff --git a/pylint/testutils/_primer/primer_run_command.py b/pylint/testutils/_primer/primer_run_command.py
index cd17d6b1d..7fb4a9ea2 100644
--- a/pylint/testutils/_primer/primer_run_command.py
+++ b/pylint/testutils/_primer/primer_run_command.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
@@ -77,7 +77,8 @@ class RunCommand(PrimerCommand):
# Duplicate code takes too long and is relatively safe
# TODO: Find a way to allow cyclic-import and compare output correctly
disables = ["--disable=duplicate-code,cyclic-import"]
- arguments = data.pylint_args + enables + disables
+ additional = ["--clear-cache-post-run=y"]
+ arguments = data.pylint_args + enables + disables + additional
output = StringIO()
reporter = JSONReporter(output)
print(f"Running 'pylint {', '.join(arguments)}'")
@@ -96,6 +97,7 @@ class RunCommand(PrimerCommand):
if fatal_msgs:
warnings.warn(
f"Encountered fatal errors while priming {package_name} !\n"
- f"{self._print_msgs(fatal_msgs)}\n\n"
+ f"{self._print_msgs(fatal_msgs)}\n\n",
+ stacklevel=2,
)
return messages, fatal_msgs
diff --git a/pylint/testutils/_run.py b/pylint/testutils/_run.py
index 0ad68868f..e0a19deca 100644
--- a/pylint/testutils/_run.py
+++ b/pylint/testutils/_run.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
"""Classes and functions used to mimic normal pylint runs.
@@ -10,10 +10,8 @@ This module is considered private and can change at any time.
from __future__ import annotations
from collections.abc import Sequence
-from typing import Any
from pylint.lint import Run as LintRun
-from pylint.lint.run import UNUSED_PARAM_SENTINEL
from pylint.reporters.base_reporter import BaseReporter
from pylint.testutils.lint_module_test import PYLINTRC
@@ -39,7 +37,6 @@ class _Run(LintRun):
args: Sequence[str],
reporter: BaseReporter | None = None,
exit: bool = True, # pylint: disable=redefined-builtin
- do_exit: Any = UNUSED_PARAM_SENTINEL,
) -> None:
args = _add_rcfile_default_pylintrc(list(args))
- super().__init__(args, reporter, exit, do_exit)
+ super().__init__(args, reporter, exit)
diff --git a/pylint/testutils/checker_test_case.py b/pylint/testutils/checker_test_case.py
index 291f52002..343eb8254 100644
--- a/pylint/testutils/checker_test_case.py
+++ b/pylint/testutils/checker_test_case.py
@@ -1,11 +1,10 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
import contextlib
-import warnings
from collections.abc import Generator, Iterator
from typing import Any
@@ -78,23 +77,8 @@ class CheckerTestCase:
assert expected_msg.line == gotten_msg.line, msg
assert expected_msg.col_offset == gotten_msg.col_offset, msg
if PY38_PLUS and not IS_PYPY or PY39_PLUS:
- # TODO: 3.0: Remove deprecated missing arguments and remove the warning
- if not expected_msg.end_line == gotten_msg.end_line:
- warnings.warn( # pragma: no cover
- f"The end_line attribute of {gotten_msg} does not match "
- f"the expected value in {expected_msg}. In pylint 3.0 correct end_line "
- "attributes will be required for MessageTest.",
- DeprecationWarning,
- stacklevel=2,
- )
- if not expected_msg.end_col_offset == gotten_msg.end_col_offset:
- warnings.warn( # pragma: no cover
- f"The end_col_offset attribute of {gotten_msg} does not match "
- f"the expected value in {expected_msg}. In pylint 3.0 correct end_col_offset "
- "attributes will be required for MessageTest.",
- DeprecationWarning,
- stacklevel=2,
- )
+ assert expected_msg.end_line == gotten_msg.end_line, msg
+ assert expected_msg.end_col_offset == gotten_msg.end_col_offset, msg
def walk(self, node: nodes.NodeNG) -> None:
"""Recursive walk on the given node."""
diff --git a/pylint/testutils/configuration_test.py b/pylint/testutils/configuration_test.py
index 8b921ceff..5ddb2c03b 100644
--- a/pylint/testutils/configuration_test.py
+++ b/pylint/testutils/configuration_test.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
"""Utility functions for configuration testing."""
diff --git a/pylint/testutils/constants.py b/pylint/testutils/constants.py
index 1c3c69d79..0d93b7e87 100644
--- a/pylint/testutils/constants.py
+++ b/pylint/testutils/constants.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
import operator
import re
diff --git a/pylint/testutils/decorator.py b/pylint/testutils/decorator.py
index ab99cbdd8..c20692132 100644
--- a/pylint/testutils/decorator.py
+++ b/pylint/testutils/decorator.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/functional/__init__.py b/pylint/testutils/functional/__init__.py
index 4840e1ba6..c1c1c5139 100644
--- a/pylint/testutils/functional/__init__.py
+++ b/pylint/testutils/functional/__init__.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
__all__ = [
"FunctionalTestFile",
diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py
index 200cee7ec..f2e636687 100644
--- a/pylint/testutils/functional/find_functional_tests.py
+++ b/pylint/testutils/functional/find_functional_tests.py
@@ -1,18 +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/main/LICENSE
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
import os
+from collections.abc import Iterator
from pathlib import Path
from pylint.testutils.functional.test_file import FunctionalTestFile
-REASONABLY_DISPLAYABLE_VERTICALLY = 48
-"""'Wet finger' number of files that are reasonable to display by an IDE."""
-SHOULD_BE_IN_THE_SAME_DIRECTORY = 5
-"""'Wet finger' as in 'in my settings there are precisely this many'."""
+REASONABLY_DISPLAYABLE_VERTICALLY = 49
+"""'Wet finger' number of files that are reasonable to display by an IDE.
+
+'Wet finger' as in 'in my settings there are precisely this many'.
+"""
IGNORED_PARENT_DIRS = {
"deprecated_relative_import",
@@ -32,11 +34,12 @@ IGNORED_PARENT_PARENT_DIRS = {
def get_functional_test_files_from_directory(
input_dir: Path | str,
+ max_file_per_directory: int = REASONABLY_DISPLAYABLE_VERTICALLY,
) -> list[FunctionalTestFile]:
"""Get all functional tests in the input_dir."""
suite = []
- _check_functional_tests_structure(Path(input_dir))
+ _check_functional_tests_structure(Path(input_dir), max_file_per_directory)
for dirpath, dirnames, filenames in os.walk(input_dir):
if dirpath.endswith("__pycache__"):
@@ -49,39 +52,88 @@ def get_functional_test_files_from_directory(
return suite
-def _check_functional_tests_structure(directory: Path) -> None:
- """Check if test directories follow correct file/folder structure."""
- # Ignore underscored directories
+def _check_functional_tests_structure(
+ directory: Path, max_file_per_directory: int
+) -> None:
+ """Check if test directories follow correct file/folder structure.
+
+ Ignore underscored directories or files.
+ """
if Path(directory).stem.startswith("_"):
return
files: set[Path] = set()
dirs: set[Path] = set()
+ def _get_files_from_dir(
+ path: Path, violations: list[tuple[Path, int]]
+ ) -> list[Path]:
+ """Return directories and files from a directory and handles violations."""
+ files_without_leading_underscore = list(
+ p for p in path.iterdir() if not p.stem.startswith("_")
+ )
+ if len(files_without_leading_underscore) > max_file_per_directory:
+ violations.append((path, len(files_without_leading_underscore)))
+ return files_without_leading_underscore
+
+ def walk(path: Path) -> Iterator[Path]:
+ violations: list[tuple[Path, int]] = []
+ violations_msgs: set[str] = set()
+ parent_dir_files = _get_files_from_dir(path, violations)
+ error_msg = (
+ "The following directory contains too many functional tests files:\n"
+ )
+ for _file_or_dir in parent_dir_files:
+ if _file_or_dir.is_dir():
+ _files = _get_files_from_dir(_file_or_dir, violations)
+ yield _file_or_dir.resolve()
+ try:
+ yield from walk(_file_or_dir)
+ except AssertionError as e:
+ violations_msgs.add(str(e).replace(error_msg, ""))
+ else:
+ yield _file_or_dir.resolve()
+ if violations or violations_msgs:
+ _msg = error_msg
+ for offending_file, number in violations:
+ _msg += f"- {offending_file}: {number} when the max is {max_file_per_directory}\n"
+ for error_msg in violations_msgs:
+ _msg += error_msg
+ raise AssertionError(_msg)
+
# Collect all sub-directories and files in directory
- for file_or_dir in directory.iterdir():
- if file_or_dir.is_file():
- if file_or_dir.suffix == ".py" and not file_or_dir.stem.startswith("_"):
- files.add(file_or_dir)
- elif file_or_dir.is_dir():
+ for file_or_dir in walk(directory):
+ if file_or_dir.is_dir():
dirs.add(file_or_dir)
- _check_functional_tests_structure(file_or_dir)
-
- assert len(files) <= REASONABLY_DISPLAYABLE_VERTICALLY, (
- f"{directory} contains too many functional tests files "
- + f"({len(files)} > {REASONABLY_DISPLAYABLE_VERTICALLY})."
- )
+ elif file_or_dir.suffix == ".py":
+ files.add(file_or_dir)
+ directory_does_not_exists: list[tuple[Path, Path]] = []
+ misplaced_file: list[Path] = []
for file in files:
possible_dir = file.parent / file.stem.split("_")[0]
- assert not possible_dir.exists(), f"{file} should go in {possible_dir}."
-
+ if possible_dir.exists():
+ directory_does_not_exists.append((file, possible_dir))
# Exclude some directories as they follow a different structure
if (
not len(file.parent.stem) == 1 # First letter sub-directories
and file.parent.stem not in IGNORED_PARENT_DIRS
and file.parent.parent.stem not in IGNORED_PARENT_PARENT_DIRS
):
- assert file.stem.startswith(
- file.parent.stem
- ), f"{file} should not go in {file.parent}"
+ if not file.stem.startswith(file.parent.stem):
+ misplaced_file.append(file)
+
+ if directory_does_not_exists or misplaced_file:
+ msg = "The following functional tests are disorganized:\n"
+ for file, possible_dir in directory_does_not_exists:
+ msg += (
+ f"- In '{directory}', '{file.relative_to(directory)}' "
+ f"should go in '{possible_dir.relative_to(directory)}'\n"
+ )
+ for file in misplaced_file:
+ msg += (
+ f"- In '{directory}', {file.relative_to(directory)} should go in a directory"
+ f" that starts with the first letters"
+ f" of '{file.stem}' (not '{file.parent.stem}')\n"
+ )
+ raise AssertionError(msg)
diff --git a/pylint/testutils/functional/lint_module_output_update.py b/pylint/testutils/functional/lint_module_output_update.py
index e4f88b3ef..8855fd1aa 100644
--- a/pylint/testutils/functional/lint_module_output_update.py
+++ b/pylint/testutils/functional/lint_module_output_update.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/functional/test_file.py b/pylint/testutils/functional/test_file.py
index 85a72daa9..5b2e4efb6 100644
--- a/pylint/testutils/functional/test_file.py
+++ b/pylint/testutils/functional/test_file.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
@@ -62,7 +62,7 @@ class FunctionalTestFile:
def __init__(self, directory: str, filename: str) -> None:
self._directory = directory
self.base = filename.replace(".py", "")
- # TODO: 2.x: Deprecate FunctionalTestFile.options and related code
+ # TODO: 3.0: Deprecate FunctionalTestFile.options and related code
# We should just parse these options like a normal configuration file.
self.options: TestFileOptions = {
"min_pyver": (2, 5),
diff --git a/pylint/testutils/functional_test_file.py b/pylint/testutils/functional_test_file.py
deleted file mode 100644
index e2bd7f59b..000000000
--- a/pylint/testutils/functional_test_file.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
-
-__all__ = [
- "FunctionalTestFile",
- "NoFileError",
- "parse_python_version",
-]
-
-import warnings
-
-from pylint.testutils.functional import (
- FunctionalTestFile,
- NoFileError,
- parse_python_version,
-)
-
-warnings.warn(
- "'pylint.testutils.functional_test_file' will be accessible from"
- " the 'pylint.testutils.functional' namespace in pylint 3.0.",
- DeprecationWarning,
- stacklevel=2,
-)
diff --git a/pylint/testutils/get_test_info.py b/pylint/testutils/get_test_info.py
index a91b1ecd2..eb2c78cfd 100644
--- a/pylint/testutils/get_test_info.py
+++ b/pylint/testutils/get_test_info.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/global_test_linter.py b/pylint/testutils/global_test_linter.py
index d1ffac599..2e0d3d170 100644
--- a/pylint/testutils/global_test_linter.py
+++ b/pylint/testutils/global_test_linter.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from pylint import checkers
from pylint.lint import PyLinter
diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py
index e139af12b..b578e3162 100644
--- a/pylint/testutils/lint_module_test.py
+++ b/pylint/testutils/lint_module_test.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
@@ -266,7 +266,7 @@ class LintModuleTest:
expected_messages: MessageCounter,
actual_output: list[OutputLine],
) -> str:
- msg = [f'Wrong results for file "{self._test_file.base}":']
+ msg = [f'Wrong message(s) raised for "{Path(self._test_file.source).name}":']
missing, unexpected = self.multiset_difference(
expected_messages, actual_messages
)
@@ -289,7 +289,7 @@ class LintModuleTest:
) -> str:
missing = set(expected_lines) - set(received_lines)
unexpected = set(received_lines) - set(expected_lines)
- error_msg = f"Wrong output for '{self._test_file.base}.txt':"
+ error_msg = f'Wrong output for "{Path(self._test_file.expected_output).name}":'
sort_by_line_number = operator.attrgetter("lineno")
if missing:
error_msg += "\n- Missing lines:\n"
diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py
index 7465fce9d..95f24cc12 100644
--- a/pylint/testutils/output_line.py
+++ b/pylint/testutils/output_line.py
@@ -1,10 +1,9 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
-import warnings
from collections.abc import Sequence
from typing import Any, NamedTuple, TypeVar
@@ -13,7 +12,6 @@ from astroid import nodes
from pylint.constants import PY38_PLUS
from pylint.interfaces import UNDEFINED, Confidence
from pylint.message.message import Message
-from pylint.testutils.constants import UPDATE_OPTION
_T = TypeVar("_T")
@@ -89,60 +87,22 @@ class OutputLine(NamedTuple):
"""
if isinstance(row, str):
row = row.split(",")
- # noinspection PyBroadException
- # pylint: disable = too-many-try-statements
try:
+ line = int(row[1])
column = cls._get_column(row[2])
- if len(row) == 5:
- warnings.warn(
- "In pylint 3.0 functional tests expected output should always include the "
- "expected confidence level, expected end_line and expected end_column. "
- "An OutputLine should thus have a length of 8.",
- DeprecationWarning,
- stacklevel=2,
- )
- return cls(
- row[0],
- int(row[1]),
- column,
- None,
- None,
- row[3],
- row[4],
- UNDEFINED.name,
- )
- if len(row) == 6:
- warnings.warn(
- "In pylint 3.0 functional tests expected output should always include the "
- "expected end_line and expected end_column. An OutputLine should thus have "
- "a length of 8.",
- DeprecationWarning,
- stacklevel=2,
- )
- return cls(
- row[0], int(row[1]), column, None, None, row[3], row[4], row[5]
- )
- if len(row) == 8:
- end_line = cls._get_py38_none_value(row[3], check_endline)
- end_column = cls._get_py38_none_value(row[4], check_endline)
- return cls(
- row[0],
- int(row[1]),
- column,
- cls._value_to_optional_int(end_line),
- cls._value_to_optional_int(end_column),
- row[5],
- row[6],
- row[7],
- )
- raise IndexError
- except Exception: # pylint: disable=broad-except
- warnings.warn(
- "Expected 'msg-symbolic-name:42:27:MyClass.my_function:The message:"
- f"CONFIDENCE' but we got '{':'.join(row)}'. Try updating the expected"
- f" output with:\npython tests/test_functional.py {UPDATE_OPTION}",
- UserWarning,
+ end_line = cls._value_to_optional_int(
+ cls._get_py38_none_value(row[3], check_endline)
+ )
+ end_column = cls._value_to_optional_int(
+ cls._get_py38_none_value(row[4], check_endline)
)
+ # symbol, line, column, end_line, end_column, node, msg, confidences
+ assert len(row) == 8
+ return cls(
+ row[0], line, column, end_line, end_column, row[5], row[6], row[7]
+ )
+ except Exception: # pylint: disable=broad-except
+ # We need this to not fail for the update script to work.
return cls("", 0, 0, None, None, "", "", "")
def to_csv(self) -> tuple[str, str, str, str, str, str, str, str]:
diff --git a/pylint/testutils/pyreverse.py b/pylint/testutils/pyreverse.py
index 20dce84dd..24fddad77 100644
--- a/pylint/testutils/pyreverse.py
+++ b/pylint/testutils/pyreverse.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
@@ -37,7 +37,9 @@ class PyreverseConfig(
all_ancestors: bool | None = None,
show_associated: int | None = None,
all_associated: bool | None = None,
+ no_standalone: bool = False,
show_builtin: bool = False,
+ show_stdlib: bool = False,
module_names: bool | None = None,
only_classnames: bool = False,
output_format: str = "dot",
@@ -58,7 +60,9 @@ class PyreverseConfig(
self.all_ancestors = all_ancestors
self.show_associated = show_associated
self.all_associated = all_associated
+ self.no_standalone = no_standalone
self.show_builtin = show_builtin
+ self.show_stdlib = show_stdlib
self.module_names = module_names
self.only_classnames = only_classnames
self.output_format = output_format
diff --git a/pylint/testutils/reporter_for_tests.py b/pylint/testutils/reporter_for_tests.py
index 62d70a38d..d3c06eecd 100644
--- a/pylint/testutils/reporter_for_tests.py
+++ b/pylint/testutils/reporter_for_tests.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
@@ -20,7 +20,7 @@ class GenericTestReporter(BaseReporter):
out: StringIO
- def __init__( # pylint: disable=super-init-not-called # See https://github.com/PyCQA/pylint/issues/4941
+ def __init__( # pylint: disable=super-init-not-called # See https://github.com/pylint-dev/pylint/issues/4941
self,
) -> None:
self.path_strip_prefix: str = getcwd() + sep
diff --git a/pylint/testutils/testing_pylintrc b/pylint/testutils/testing_pylintrc
index ba5318b51..9429b858f 100644
--- a/pylint/testutils/testing_pylintrc
+++ b/pylint/testutils/testing_pylintrc
@@ -7,3 +7,7 @@ disable=
suppressed-message,
locally-disabled,
useless-suppression,
+
+enable=
+ deprecated-pragma,
+ use-symbolic-message-instead,
diff --git a/pylint/testutils/tokenize_str.py b/pylint/testutils/tokenize_str.py
index 13295fe51..dc9ada72a 100644
--- a/pylint/testutils/tokenize_str.py
+++ b/pylint/testutils/tokenize_str.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations
diff --git a/pylint/testutils/unittest_linter.py b/pylint/testutils/unittest_linter.py
index a519680f1..84fc53bc8 100644
--- a/pylint/testutils/unittest_linter.py
+++ b/pylint/testutils/unittest_linter.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
# pylint: disable=duplicate-code
diff --git a/pylint/testutils/utils.py b/pylint/testutils/utils.py
index 292e991c2..1ff999b28 100644
--- a/pylint/testutils/utils.py
+++ b/pylint/testutils/utils.py
@@ -1,6 +1,6 @@
# 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
-# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
+# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
from __future__ import annotations