Tests: exclude test folder itself from autmatic dataclass checks
This commit is contained in:
@@ -10,6 +10,15 @@ from clan_cli.api.util import JSchemaTypeError, type_to_dict
|
|||||||
from clan_cli.errors import ClanError
|
from clan_cli.errors import ClanError
|
||||||
|
|
||||||
|
|
||||||
|
def should_skip(file_path: Path, excludes: list[Path]) -> bool:
|
||||||
|
file_path = file_path.resolve() # Ensure absolute path
|
||||||
|
for exclude in excludes:
|
||||||
|
exclude = exclude.resolve()
|
||||||
|
if exclude in file_path.parents or exclude == file_path:
|
||||||
|
return True # Skip this file
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def find_dataclasses_in_directory(
|
def find_dataclasses_in_directory(
|
||||||
directory: Path, exclude_paths: list[str] | None = None
|
directory: Path, exclude_paths: list[str] | None = None
|
||||||
) -> list[tuple[Path, str]]:
|
) -> list[tuple[Path, str]]:
|
||||||
@@ -34,8 +43,7 @@ def find_dataclasses_in_directory(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = Path(root) / file
|
file_path = Path(root) / file
|
||||||
|
if should_skip(file_path, excludes):
|
||||||
if file_path in excludes:
|
|
||||||
print(f"Skipping dataclass check for file: {file_path}")
|
print(f"Skipping dataclass check for file: {file_path}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -123,6 +131,7 @@ def test_all_dataclasses() -> None:
|
|||||||
"api/__init__.py",
|
"api/__init__.py",
|
||||||
"cmd.py", # We don't want the UI to have access to the cmd module anyway
|
"cmd.py", # We don't want the UI to have access to the cmd module anyway
|
||||||
"async_run.py", # We don't want the UI to have access to the async_run module anyway
|
"async_run.py", # We don't want the UI to have access to the async_run module anyway
|
||||||
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
||||||
cli_path = Path("clan_cli").resolve()
|
cli_path = Path("clan_cli").resolve()
|
||||||
|
|||||||
Reference in New Issue
Block a user