This is an automated email from the ASF dual-hosted git repository.
jason810496 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b0721979b92 Fix connection metadata test across Python versions
(#72293)
b0721979b92 is described below
commit b0721979b92e4cddc13afe294b5a034ec90d0e49
Author: Aaron Chen <[email protected]>
AuthorDate: Mon Aug 31 02:31:02 2026 +0800
Fix connection metadata test across Python versions (#72293)
---
.../api_fastapi/core_api/services/ui/test_connections.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/services/ui/test_connections.py
b/airflow-core/tests/unit/api_fastapi/core_api/services/ui/test_connections.py
index 3800a6c901f..f8442801b0f 100644
---
a/airflow-core/tests/unit/api_fastapi/core_api/services/ui/test_connections.py
+++
b/airflow-core/tests/unit/api_fastapi/core_api/services/ui/test_connections.py
@@ -350,11 +350,10 @@ class TestGetHooksWithMockedFab:
def test_patched_helpers_return_the_mock_substitutes(self):
"""
- The substitutes are reached through ``wtforms.validators``, not
``sys.modules``.
+ Exactly one of the two ``wtforms.validators`` mocks receives the
substitute.
- ``mock.patch`` resolves ``wtforms.validators.any_of`` by attribute
lookup on the ``wtforms``
- mock, which is a different object from the
``sys.modules["wtforms.validators"]`` mock that
- ``from wtforms.validators import any_of`` would return.
+ Different Python versions can resolve the dotted patch target to
either object, so check
+ both paths without relying on a particular resolution strategy.
"""
captured = {}
@@ -363,14 +362,17 @@ class TestGetHooksWithMockedFab:
import wtforms
captured["label"] = flask_babel.lazy_gettext("Some label")
- captured["validator"] = wtforms.validators.any_of(["a", "b"])
+ captured["validators"] = [
+ sys.modules["wtforms.validators"].any_of(["a", "b"]),
+ wtforms.validators.any_of(["a", "b"]),
+ ]
return mock.MagicMock(spec=ProvidersManager)
self.call_without_fab_modules(find_spec_raises, read_patched_helpers)
assert captured["label"] == "Some label"
- assert isinstance(captured["validator"], HookMetaService.MockEnum)
- assert captured["validator"].allowed_values == ["a", "b"]
+ substitutes = [v for v in captured["validators"] if isinstance(v,
HookMetaService.MockEnum)]
+ assert [substitute.allowed_values for substitute in substitutes] ==
[["a", "b"]]
class TestHookMetaData: