gtxu commented on PR #70960:
URL: https://github.com/apache/airflow/pull/70960#issuecomment-5263155070
Found out the root cause CI failures (3/3 runs) targeting
`TestHttpAsyncHookSrvLookup::test_run_resolves_srv_record`.
The test was failing with a real network query exception
(`dns.resolver.NoAnswer`), bypassing the mock, yet consistently passing in
local environments.
In Python 3.10(CI Env), `mock.patch` uses `_dot_lookup` (which calls
`getattr`), meaning it successfully patched the *stale* attribute on the `dns`
package. When the hook subsequently executed `import dns.asyncresolver`, it
found no entry in `sys.modules`, loaded a fresh real module, and bypassed the
mock entirely.
Python 3.12 uses `pkgutil.resolve_name`, which performs a real import and
self-heals, explaining why this is not identified in my local test.
Added a `stable_dns_import` fixture for both SRV test classes.
This fixture re-registers the submodules:
```python
importlib.import_module("dns.resolver")
importlib.import_module("dns.asyncresolver")
--
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]