-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathconftest.py
98 lines (71 loc) · 2.46 KB
/
conftest.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# 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
from collections.abc import Callable, Sequence
import pytest
from astroid.nodes.scoped_nodes import Module
from pylint.lint import augmented_sys_path, discover_package_path
from pylint.pyreverse.inspector import Project, project_from_files
from pylint.testutils.pyreverse import PyreverseConfig
from pylint.typing import GetProjectCallable
@pytest.fixture()
def default_args() -> Sequence[str]:
"""Provides default command-line arguments for tests."""
return ["data"]
@pytest.fixture()
def default_config() -> PyreverseConfig:
"""Provides default configuration for tests."""
return PyreverseConfig()
@pytest.fixture()
def colorized_dot_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="dot",
colorized=True,
)
@pytest.fixture()
def no_standalone_dot_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="dot",
no_standalone=True,
)
@pytest.fixture()
def puml_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="puml",
)
@pytest.fixture()
def colorized_puml_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="puml",
colorized=True,
)
@pytest.fixture()
def mmd_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="mmd",
colorized=False,
)
@pytest.fixture()
def html_config() -> PyreverseConfig:
return PyreverseConfig(
output_format="html",
colorized=False,
)
@pytest.fixture()
def depth_limited_config(default_max_depth: int) -> PyreverseConfig:
return PyreverseConfig(
max_depth=default_max_depth,
)
@pytest.fixture(scope="session")
def get_project() -> GetProjectCallable:
def _get_project(module: str, name: str | None = "No Name") -> Project:
"""Return an astroid project representation."""
def _astroid_wrapper(
func: Callable[[str], Module], modname: str, _verbose: bool = False
) -> Module:
return func(modname)
with augmented_sys_path([discover_package_path(module, [])]):
project = project_from_files([module], _astroid_wrapper, project_name=name)
return project
return _get_project