Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix unit test case sensitivity #993

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions tests/artifact/test_local_artifact.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

"""Test the local artifact utilities."""

import os
import tempfile
from pathlib import Path

import pytest
Expand All @@ -18,6 +19,23 @@
from macaron.errors import LocalArtifactFinderError


def is_case_sensitive_filesystem() -> bool:
"""Check if the filesystem is case-sensitive."""
with tempfile.TemporaryDirectory() as temp_dir:
lower = os.path.join(temp_dir, "a")
upper = os.path.join(temp_dir, "A")

os.mkdir(lower)

try:
os.mkdir(upper)
# if upper is not treated the same as lower -> case sensitive
return True
except FileExistsError:
# upper is treated the same as lower -> case insensitive
return False


@pytest.mark.parametrize(
("purl_str", "expectation"),
[
Expand Down Expand Up @@ -205,13 +223,20 @@ def test_get_local_artifact_paths_succeeded_pypi(tmp_path: Path) -> None:
python_venv_path = f"{tmp_path_str}/.venv/lib/python3.11/site-packages"

# We are also testing if the patterns match case-insensitively.
pypi_artifact_paths = [
f"{python_venv_path}/macaron",
f"{python_venv_path}/macaron-0.13.0.dist-info",
f"{python_venv_path}/Macaron-0.13.0.dist-info",
f"{python_venv_path}/macaron-0.13.0.data",
f"{python_venv_path}/Macaron-0.13.0.data",
]
if not is_case_sensitive_filesystem():
pypi_artifact_paths = [
f"{python_venv_path}/macaron",
f"{python_venv_path}/macaron-0.13.0.dist-info",
f"{python_venv_path}/macaron-0.13.0.data",
]
else:
pypi_artifact_paths = [
f"{python_venv_path}/macaron",
f"{python_venv_path}/macaron-0.13.0.dist-info",
f"{python_venv_path}/Macaron-0.13.0.dist-info",
f"{python_venv_path}/macaron-0.13.0.data",
f"{python_venv_path}/Macaron-0.13.0.data",
]

os.makedirs(python_venv_path)

Expand Down
Loading