Skip to content

Commit b213021

Browse files
committed
Update mock to match updated importlib.resources
1 parent 19dc518 commit b213021

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/core/test_providers_manager.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ def test_warning_logs_not_generated(self):
118118

119119
@patch('airflow.providers_manager.importlib.import_module')
120120
def test_hooks(self, mock_import_module):
121-
# importlib-resources>=5.2 relies on importing the containing module to
122-
# read its content. The provider manager needs to read the validation
123-
# schema 'provider_info.schema.json'. Not sure why this needs to be
124-
# called twice. Also see comment on the assert at the end of the function.
121+
# importlib.resources relies on importing the containing module to read
122+
# its content. The provider manager needs to read two validation schemas
123+
# 'provider_info.schema.json' and 'customized_form_field_behaviours.schema.json'.
125124
mock_import_module.side_effect = [airflow, airflow]
126125

127126
with pytest.warns(expected_warning=None) as warning_records:
@@ -132,12 +131,12 @@ def test_hooks(self, mock_import_module):
132131
assert [] == [w.message for w in warning_records.list if "hook-class-names" in str(w.message)]
133132
assert len(self._caplog.records) == 0
134133

135-
# The stdlib importlib.resources implementation in 3.7 through 3.9 does
136-
# not rely on importlib.import_module, so the function should not be
137-
# called. The implementation for 3.10+ and the backport to 3.6 uses it
138-
# to import the top-level 'airflow' for 'provider_info.schema.json'.
139-
# Also see comment on mocking at the beginning of the function.
140-
if (3, 7) <= sys.version_info < (3, 10):
134+
# The stdlib importlib.resources implementation in 3.9 does not rely on
135+
# importlib.import_module, so the function should not be called. The
136+
# implementation for 3.10+ and the backport we use for up to 3.8 uses it
137+
# to import the top-level 'airflow' for the two schema files. Also see
138+
# comment on mocking at the beginning of the function.
139+
if sys.version_info[:2] == (3, 9):
141140
assert mock_import_module.mock_calls == []
142141
else:
143142
assert mock_import_module.mock_calls == [call("airflow"), call("airflow")]

0 commit comments

Comments
 (0)