Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ def is_third_party_package(file_path: Path) -> bool:
return False

third_party_packages = _load_third_party_packages()
return distribution.name in third_party_packages
# Perform case-insensitive comparison to handle packages like 'Django' vs 'django'
return distribution.name.lower() in third_party_packages


@lru_cache(maxsize=1024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,18 @@ def test_is_third_party_package_not_in_list(self, mock_load_packages, mock_resol

self.assertFalse(result)

@patch("amazon.opentelemetry.distro.code_correlation.internal.packages_resolver.resolve_package_from_filename")
@patch("amazon.opentelemetry.distro.code_correlation.internal.packages_resolver._load_third_party_packages")
def test_is_third_party_package_case_insensitive_match(self, mock_load_packages, mock_resolve):
"""Test case-insensitive detection of third-party package."""
# Test with uppercase package name in distribution but lowercase in third-party list
mock_resolve.return_value = Distribution(name="Django", version="4.2.0")
mock_load_packages.return_value = {"django", "requests", "urllib3"}

result = is_third_party_package(Path("/path/to/Django/__init__.py"))

self.assertTrue(result)


class TestIsUserCode(TestCase):
"""Test the is_user_code function."""
Expand Down
Loading