Skip to content

Commit

Permalink
Remove Python 3.9 port
Browse files Browse the repository at this point in the history
Python 3.9 is now the minimum supported version, so `is_relative_to` is available.
  • Loading branch information
john-kurkowski committed Nov 4, 2024
1 parent 655c23f commit 6ddea47
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions tests/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,10 @@ def test_cache_cleared_by_other_process(
extract("google.com")
orig_unlink = os.unlink

def is_relative_to(path: Path, other_path: str | Path) -> bool:
"""Return True if path is relative to other_path or False.
Taken from the Python 3.9 standard library.
Reference: https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.is_relative_to
"""
try:
path.relative_to(other_path)
return True
except ValueError:
return False

def evil_unlink(filename: str | Path) -> None:
"""Simulate someone deletes the file right before we try to."""
if (isinstance(filename, str) and filename.startswith(cache_dir)) or (
isinstance(filename, Path) and is_relative_to(filename, cache_dir)
isinstance(filename, Path) and filename.is_relative_to(cache_dir)
):
orig_unlink(filename)
orig_unlink(filename)
Expand Down

0 comments on commit 6ddea47

Please sign in to comment.