From 6a3a1320af0b0ca0251be26719755631a2f0369a Mon Sep 17 00:00:00 2001 From: Achraf Maghous Date: Mon, 17 Feb 2025 13:30:11 +0100 Subject: [PATCH] chore: refactoring is_case_sensitive_filesystem using tmp_path Using tmp_path made the use of st_ino obselete, now we create paths using touch method Signed-off-by: Achraf Maghous --- tests/artifact/test_local_artifact.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/artifact/test_local_artifact.py b/tests/artifact/test_local_artifact.py index 01885d8b0..260a1c566 100644 --- a/tests/artifact/test_local_artifact.py +++ b/tests/artifact/test_local_artifact.py @@ -4,7 +4,6 @@ """Test the local artifact utilities.""" import os -import tempfile from pathlib import Path import pytest @@ -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(