Skip to content

Commit

Permalink
chore: refactoring is_case_sensitive_filesystem using tmp_path
Browse files Browse the repository at this point in the history
Using tmp_path made the use of st_ino obselete, now we create paths using touch method

Signed-off-by: Achraf Maghous <achraf.maghous@oracle.com>
  • Loading branch information
achrafmag committed Feb 17, 2025
1 parent c68feee commit 6a3a132
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/artifact/test_local_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""Test the local artifact utilities."""

import os
import tempfile
from pathlib import Path

import pytest
Expand All @@ -21,14 +20,21 @@

def is_case_sensitive_filesystem() -> bool:
"""Check if current filesystem is case-sensitive."""
with tempfile.NamedTemporaryFile(prefix="Tmp") as tmp:
base = tmp.name
lower = base.lower()
upper = base.upper()

return not (os.path.exists(lower) or os.path.exists(upper)) or (
os.path.exists(lower) and os.path.exists(upper) and os.stat(lower).st_ino != os.stat(upper).st_ino
)
tmp_path = Path(".")

# using "/" overloaded operator as __truediv__ in Path class to build a lower and upper path
lower = tmp_path / "a"
upper = tmp_path / "A"

try:
lower.touch()
upper.touch()
return not upper.exists()
finally:
if lower.exists():
lower.unlink()
if upper.exists():
upper.unlink()


@pytest.mark.parametrize(
Expand Down

0 comments on commit 6a3a132

Please sign in to comment.