blob: 220e2c0b2821aafc894dbdc1e6f4f9895286a982 (
plain)
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
48
49
|
# 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
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 == ""
expected_path_to_lint = (
PRIMER_DIRECTORY_PATH / "pallets" / "flask" / "src" / "flask"
)
assert package_to_lint.pylint_args == [str(expected_path_to_lint), "--rcfile="]
|