Skip to content

Commit

Permalink
Apply Johan's code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mknorps committed Jan 8, 2024
1 parent 83ea1f2 commit fb17603
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions fawltydeps/types.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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!")
Expand Down
1 change: 0 additions & 1 deletion tests/project_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
19 changes: 8 additions & 11 deletions tests/test_dir_traversal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test core functionality of DirectoryTraversal class."""
import os
import sys
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
Expand Down Expand Up @@ -183,8 +182,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"]),
Expand All @@ -195,9 +194,9 @@ class DirectoryTraversalVector(Generic[T]):
"mutual_symlinks__are_traversed_once",
given=[
RelativeSymlink(
os.path.join("sub1", "rel_link_sub2"), os.path.join("..", "sub2")
str(Path("sub1", "rel_link_sub2")), str(Path("..", "sub2"))
),
AbsoluteSymlink(os.path.join("sub2", "abs_link_sub1"), "sub1"),
AbsoluteSymlink(str(Path("sub2", "abs_link_sub1")), "sub1"),
],
expect_alternatives=[
[
Expand All @@ -224,10 +223,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=[
Expand All @@ -238,8 +235,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=[
Expand Down

0 comments on commit fb17603

Please sign in to comment.