Andrushika commented on code in PR #76890:
URL: https://github.com/apache/airflow/pull/76890#discussion_r4548186521
##########
shared/module_loading/tests/module_loading/test_entry_points.py:
##########
@@ -97,17 +99,44 @@ 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()
+
+
+# When the directory name gives no name, _normalized_name reads METADATA
instead: a missing file
+# raises TypeError, a file without a Name field raises KeyError.
Review Comment:
Sorry for missing this, I didn't check other versions... Since the error
type depends on the version, I went back to `except Exception` here and removed
the wrong comment in the test. Thanks!
--
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]