Skip to content

Commit 63a68ab

Browse files
committed
Add test for test_excluded_python_paths and update description
1 parent ca76572 commit 63a68ab

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

exasol/toolbox/config.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ def valid_version_string(version_string: str) -> str:
2020

2121
ValidVersionStr = Annotated[str, AfterValidator(valid_version_string)]
2222

23+
DEFAULT_EXCLUDED_PATHS = {
24+
".eggs",
25+
".html-documentation",
26+
".poetry",
27+
".sonar",
28+
".venv",
29+
"dist",
30+
"venv",
31+
}
32+
2333

2434
class BaseConfig(BaseModel):
2535
"""
@@ -55,7 +65,7 @@ class BaseConfig(BaseModel):
5565
This is used to extend the default excluded_python_paths. If a more general
5666
path that would be seen in other projects, like .venv, needs to be added into
5767
this argument, please instead modify the
58-
:meth:`exasol.toolbox.config.BaseConfig.excluded_paths` attribute.
68+
`exasol.toolbox.config.DEFAULT_EXCLUDED_PATHS`.
5969
""",
6070
)
6171
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
@@ -88,17 +98,8 @@ def excluded_python_paths(self) -> tuple[str, ...]:
8898
source_path, like excluding `dist`, `.eggs`. As such, this property is used to
8999
exclude such undesired paths.
90100
"""
91-
default_excluded_paths = {
92-
".eggs",
93-
".html-documentation",
94-
".poetry",
95-
".sonar",
96-
".venv",
97-
"dist",
98-
"venv",
99-
}
100101
return tuple(
101-
default_excluded_paths.union(set(self.add_to_excluded_python_paths))
102+
DEFAULT_EXCLUDED_PATHS.union(set(self.add_to_excluded_python_paths))
102103
)
103104

104105
@computed_field # type: ignore[misc]

test/unit/config_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pydantic_core._pydantic_core import ValidationError
33

44
from exasol.toolbox.config import (
5+
DEFAULT_EXCLUDED_PATHS,
56
BaseConfig,
67
valid_version_string,
78
)
@@ -66,3 +67,22 @@ def test_minimum_python_version():
6667
def test_pyupgrade_argument(minimum_python_version):
6768
conf = BaseConfig(python_versions=("3.11", minimum_python_version, "3.12"))
6869
assert conf.pyupgrade_argument == ("--py310-plus",)
70+
71+
72+
@pytest.mark.parametrize(
73+
"add_to_excluded_python_paths,expected",
74+
[
75+
pytest.param((), tuple(DEFAULT_EXCLUDED_PATHS), id="no_additions"),
76+
pytest.param(
77+
(next(iter(DEFAULT_EXCLUDED_PATHS)),),
78+
tuple(DEFAULT_EXCLUDED_PATHS),
79+
id="duplicate_addition",
80+
),
81+
pytest.param(
82+
("dummy",), tuple(DEFAULT_EXCLUDED_PATHS) + ("dummy",), id="add_a_new_entry"
83+
),
84+
],
85+
)
86+
def test_excluded_python_paths(add_to_excluded_python_paths, expected):
87+
conf = BaseConfig(add_to_excluded_python_paths=add_to_excluded_python_paths)
88+
assert sorted(conf.excluded_python_paths) == sorted(expected)

0 commit comments

Comments
 (0)