|
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. |
2 | 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. |
3 | 3 |
|
4 | 4 | """Test the local artifact utilities.""" |
5 | 5 |
|
6 | 6 | import os |
| 7 | +import tempfile |
7 | 8 | from pathlib import Path |
8 | 9 |
|
9 | 10 | import pytest |
|
18 | 19 | from macaron.errors import LocalArtifactFinderError |
19 | 20 |
|
20 | 21 |
|
| 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 | + |
21 | 39 | @pytest.mark.parametrize( |
22 | 40 | ("purl_str", "expectation"), |
23 | 41 | [ |
@@ -205,13 +223,20 @@ def test_get_local_artifact_paths_succeeded_pypi(tmp_path: Path) -> None: |
205 | 223 | python_venv_path = f"{tmp_path_str}/.venv/lib/python3.11/site-packages" |
206 | 224 |
|
207 | 225 | # 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 | + ] |
215 | 240 |
|
216 | 241 | os.makedirs(python_venv_path) |
217 | 242 |
|
|
0 commit comments