uranusjr commented on code in PR #76890:
URL: https://github.com/apache/airflow/pull/76890#discussion_r4559483992


##########
shared/module_loading/tests/module_loading/test_entry_points.py:
##########
@@ -97,17 +99,46 @@ def 
test_entry_points_with_dist_same_dist_in_two_versions_returns_first_only():
     ]
 
 
-# No metadata file at all, or metadata without a Name field (the key is 
absent, not None).
[email protected]("dist_metadata", [None, {"Version": "1.0.0"}], 
ids=["no-metadata", "no-name"])
-def 
test_entry_points_with_dist_without_name_are_not_deduplicated(dist_metadata):
+def test_entry_points_with_dist_deduplicates_without_reading_metadata():
+    distributions = [
+        MockDistribution("apache-airflow-providers-foo", 
[metadata.EntryPoint("a", "b", "group_x")]),
+        MockDistribution("apache_airflow_providers_foo", 
[metadata.EntryPoint("c", "d", "group_x")]),
+        MockDistribution("apache-airflow-providers-bar", 
[metadata.EntryPoint("e", "f", "group_x")]),
+    ]
+
+    with (
+        mock.patch("airflow_shared.module_loading.metadata", 
MockMetadata(distributions)),
+        mock.patch.object(
+            MockDistribution, "metadata", create=True, 
new_callable=mock.PropertyMock
+        ) as metadata_property,
+    ):
+        entries = list(entry_points_with_dist("group_x"))
+
+    assert [ep.name for ep, _ in entries] == ["a", "e"]
+    metadata_property.assert_not_called()
+
+
[email protected](
+    "error",
+    [TypeError, KeyError, FileNotFoundError, AttributeError],
+    ids=["stdlib", "importlib-metadata-8", "importlib-metadata-10-no-file", 
"no-attribute"],

Review Comment:
   MetadataNotFound (a FileNotFoundError subclass) is already raised on 
importlib_metadata 9.0.1, so `importlib-metadata-9-no-file` (or just no-file) 
would be more accurate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to