Skip to content

Commit 4fcd7e8

Browse files
authored
test: fix unit test case sensitivity (#993)
Signed-off-by: Achraf Maghous <[email protected]>
1 parent 2510d7d commit 4fcd7e8

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

tests/artifact/test_local_artifact.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""Test the local artifact utilities."""
55

66
import os
7+
import tempfile
78
from pathlib import Path
89

910
import pytest
@@ -18,6 +19,23 @@
1819
from macaron.errors import LocalArtifactFinderError
1920

2021

22+
def is_case_sensitive_filesystem() -> bool:
23+
"""Check if the filesystem is case-sensitive."""
24+
with tempfile.TemporaryDirectory() as temp_dir:
25+
lower = os.path.join(temp_dir, "a")
26+
upper = os.path.join(temp_dir, "A")
27+
28+
os.mkdir(lower)
29+
30+
try:
31+
os.mkdir(upper)
32+
# if upper is not treated the same as lower -> case sensitive
33+
return True
34+
except FileExistsError:
35+
# upper is treated the same as lower -> case insensitive
36+
return False
37+
38+
2139
@pytest.mark.parametrize(
2240
("purl_str", "expectation"),
2341
[
@@ -205,13 +223,20 @@ def test_get_local_artifact_paths_succeeded_pypi(tmp_path: Path) -> None:
205223
python_venv_path = f"{tmp_path_str}/.venv/lib/python3.11/site-packages"
206224

207225
# We are also testing if the patterns match case-insensitively.
208-
pypi_artifact_paths = [
209-
f"{python_venv_path}/macaron",
210-
f"{python_venv_path}/macaron-0.13.0.dist-info",
211-
f"{python_venv_path}/Macaron-0.13.0.dist-info",
212-
f"{python_venv_path}/macaron-0.13.0.data",
213-
f"{python_venv_path}/Macaron-0.13.0.data",
214-
]
226+
if not is_case_sensitive_filesystem():
227+
pypi_artifact_paths = [
228+
f"{python_venv_path}/macaron",
229+
f"{python_venv_path}/macaron-0.13.0.dist-info",
230+
f"{python_venv_path}/macaron-0.13.0.data",
231+
]
232+
else:
233+
pypi_artifact_paths = [
234+
f"{python_venv_path}/macaron",
235+
f"{python_venv_path}/macaron-0.13.0.dist-info",
236+
f"{python_venv_path}/Macaron-0.13.0.dist-info",
237+
f"{python_venv_path}/macaron-0.13.0.data",
238+
f"{python_venv_path}/Macaron-0.13.0.data",
239+
]
215240

216241
os.makedirs(python_venv_path)
217242

0 commit comments

Comments
 (0)