diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-11-24 13:10:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 13:10:52 +0100 |
commit | 5e9d20dc32768e873ab84bc4ed0b489fdda40672 (patch) | |
tree | 26e1018b2ff6f299b23d93fa3160e0bd704966cd /tests/testutils | |
parent | e8fa46928d91893723a9a038fde2d274d535fd1f (diff) | |
download | pylint-git-5e9d20dc32768e873ab84bc4ed0b489fdda40672.tar.gz |
Primer tests "à la mypy" (#5173)
* Add changelog and warning about unstable API in testutil
* Add primer tests, (running pylint on external libs during tests)
In order to anticipate crash/fatal messages, false positives are harder
to anticipate. Follow-up will be #5359 and later on #5364
Add '__tracebackhide__ = True' so the traceback is manageable
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/test_package_to_lint.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/testutils/test_package_to_lint.py b/tests/testutils/test_package_to_lint.py new file mode 100644 index 000000000..bf90db3e7 --- /dev/null +++ b/tests/testutils/test_package_to_lint.py @@ -0,0 +1,48 @@ +# 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 pylint.testutils.primer import PRIMER_DIRECTORY_PATH, PackageToLint + + +def test_package_to_lint() -> None: + """Test that the PackageToLint is instantiated correctly.""" + expected_dir_path = PRIMER_DIRECTORY_PATH / "vimeo" / "graph-explorer" + expected_path_to_lint = expected_dir_path / "graph_explorer" + expected_pylintrc_path = expected_dir_path / ".pylintrcui" + + args = ["--ignore-pattern='re*'"] + package_to_lint = PackageToLint( + url="https://github.com/vimeo/graph-explorer.git", + branch="main", + directories=["graph_explorer"], + pylintrc_relpath=".pylintrcui", + pylint_additional_args=args, + ) + + assert package_to_lint.url == "https://github.com/vimeo/graph-explorer.git" + assert package_to_lint.branch == "main" + assert package_to_lint.directories == ["graph_explorer"] + assert package_to_lint.pylintrc_relpath == ".pylintrcui" + assert package_to_lint.pylint_additional_args == args + assert package_to_lint.paths_to_lint == [str(expected_path_to_lint)] + assert package_to_lint.clone_directory == expected_dir_path + assert package_to_lint.pylintrc == expected_pylintrc_path + expected_args = [ + str(expected_path_to_lint), + f"--rcfile={expected_pylintrc_path}", + ] + args + assert package_to_lint.pylint_args == expected_args + + +def test_package_to_lint_default_value() -> None: + """Test that the PackageToLint is instantiated correctly with default value.""" + package_to_lint = PackageToLint( + url="https://github.com/pallets/flask.git", + branch="main", + directories=["src/flask"], # Must work on Windows (src\\flask) + ) + assert package_to_lint.pylintrc is None + expected_path_to_lint = ( + PRIMER_DIRECTORY_PATH / "pallets" / "flask" / "src" / "flask" + ) + assert package_to_lint.pylint_args == [str(expected_path_to_lint)] |