From 31d3ba2a987b9cba6cc4ef7ce54434ac31c38b56 Mon Sep 17 00:00:00 2001 From: Maria Knorps Date: Mon, 8 Jan 2024 10:49:40 +0100 Subject: [PATCH] Apply Johan's code review suggestions --- fawltydeps/types.py | 3 +-- tests/project_helpers.py | 1 - tests/test_dir_traversal.py | 20 ++++++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/fawltydeps/types.py b/fawltydeps/types.py index 47eedfee..4b46d1cd 100644 --- a/fawltydeps/types.py +++ b/fawltydeps/types.py @@ -1,6 +1,5 @@ """Common types used across FawltyDeps.""" -import os import sys from abc import ABC, abstractmethod from dataclasses import asdict, dataclass, field, replace @@ -159,7 +158,7 @@ def __post_init__(self) -> None: # Support Windows projects if sys.platform.startswith("win"): if (self.path.parent.parent / "Scripts" / "python.exe").is_file(): - if self.path.match(os.path.join("Lib", "site-packages")): + if self.path.match(str(Path("Lib", "site-packages"))): return # also ok raise ValueError(f"{self.path} is not a valid dir for Python packages!") diff --git a/tests/project_helpers.py b/tests/project_helpers.py index 8161cfdf..472f2ac0 100644 --- a/tests/project_helpers.py +++ b/tests/project_helpers.py @@ -296,7 +296,6 @@ def from_toml(cls, name: str, data: TomlData) -> "BaseExperiment": def get_venv_dir(self, cache: pytest.Cache) -> Path: """Get this venv's dir and create it if necessary.""" - print(f"EXPERIMENT REQUIREMENTS: {self.requirements}") return CachedExperimentVenv(self.requirements)(cache) diff --git a/tests/test_dir_traversal.py b/tests/test_dir_traversal.py index b459c906..a87773e6 100644 --- a/tests/test_dir_traversal.py +++ b/tests/test_dir_traversal.py @@ -183,8 +183,8 @@ class DirectoryTraversalVector(Generic[T]): DirectoryTraversalVector( "symlinks_to_parent__are_not_traversed", given=[ - RelativeSymlink(os.path.join("sub", "rel_parent"), ".."), - AbsoluteSymlink(os.path.join("sub", "abs_parent"), "."), + RelativeSymlink(str(Path("sub", "rel_parent")), ".."), + AbsoluteSymlink(str(Path("sub", "abs_parent")), "."), ], expect=[ ExpectedTraverseStep(".", subdirs=["sub"]), @@ -194,10 +194,8 @@ class DirectoryTraversalVector(Generic[T]): DirectoryTraversalVector( "mutual_symlinks__are_traversed_once", given=[ - RelativeSymlink( - os.path.join("sub1", "rel_link_sub2"), os.path.join("..", "sub2") - ), - AbsoluteSymlink(os.path.join("sub2", "abs_link_sub1"), "sub1"), + RelativeSymlink(str(Path("sub1", "rel_link_sub2")), str(Path("..", "sub2"))), + AbsoluteSymlink(str(Path("sub2", "abs_link_sub1")), "sub1"), ], expect_alternatives=[ [ @@ -224,10 +222,8 @@ class DirectoryTraversalVector(Generic[T]): DirectoryTraversalVector( "relative_symlink_to_dir_elsewhere__is_traversed", given=[ - File(os.path.join("elsewhere", "file")), - RelativeSymlink( - os.path.join("here", "symlink"), os.path.join("..", "elsewhere") - ), + File(str(Path("elsewhere", "file"))), + RelativeSymlink(str(Path("here", "symlink")), str(Path("..", "elsewhere"))), ], add=[AddCall(path="here")], expect=[ @@ -238,8 +234,8 @@ class DirectoryTraversalVector(Generic[T]): DirectoryTraversalVector( "absolute_symlink_to_dir_elsewhere__is_traversed", given=[ - File(os.path.join("elsewhere", "file")), - AbsoluteSymlink(os.path.join("here", "symlink"), "elsewhere"), + File(str(Path("elsewhere", "file"))), + AbsoluteSymlink(str(Path("here", "symlink")), "elsewhere"), ], add=[AddCall(path="here")], expect=[