This is an automated email from the ASF dual-hosted git repository.

henry3260 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 e211b451148 Stop airflowctl connection-refused test depending on the 
local network (#76077)
e211b451148 is described below

commit e211b4511486e9345fb7afdc7ad2288a43b2b491
Author: Shahar Epstein <[email protected]>
AuthorDate: Fri Oct 30 21:13:46 2026 +0200

    Stop airflowctl connection-refused test depending on the local network 
(#76077)
    
    test_server_connection_refused connected to http://localhost and expected
    the kernel to refuse it. That fails on any machine where something listens
    on port 80, and on WSL2 with mirrored networking, where a closed loopback
    port times out instead of refusing. The test now raises the ConnectError
    from a mock transport, which still exercises the conversion to
    AirflowCtlConnectionException.
---
 airflow-ctl/tests/airflow_ctl/api/test_operations.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/airflow-ctl/tests/airflow_ctl/api/test_operations.py 
b/airflow-ctl/tests/airflow_ctl/api/test_operations.py
index 6f93d4f20b3..1c7b0f45cf7 100644
--- a/airflow-ctl/tests/airflow_ctl/api/test_operations.py
+++ b/airflow-ctl/tests/airflow_ctl/api/test_operations.py
@@ -158,7 +158,12 @@ class TestBaseOperations:
         }
 
     def test_server_connection_refused(self):
-        client = make_api_client(base_url="http://localhost";)
+        # A real connect to localhost depends on the machine: a local web 
server answers, and WSL2
+        # mirrored networking turns a closed loopback port into a timeout 
instead of a refusal.
+        def handle_request(request: httpx.Request) -> httpx.Response:
+            raise httpx.ConnectError("[Errno 111] Connection refused", 
request=request)
+
+        client = make_api_client(transport=httpx.MockTransport(handle_request))
         with pytest.raises(
             AirflowCtlConnectionException, match="Connection refused. Is the 
API server running?"
         ):

Reply via email to