potiuk opened a new pull request, #66678:
URL: https://github.com/apache/airflow/pull/66678

   ## Summary
   
   PR #64465 (SFTP async refactor) changed the production code from
   `await ssh_conn.start_sftp_client()` to
   `async with ssh_conn.start_sftp_client() as sftp:` (same for
   `sftp.open()`), but the `sftp_hook_mocked` fixture in
   `providers/sftp/tests/conftest.py` was still set up as if those methods
   were awaited.
   
   `AsyncMock(spec=SSHClientConnection)` auto-makes `start_sftp_client` an
   `AsyncMock` whose call returns a *coroutine* — not an async context
   manager — so every `TestSFTPHookAsync` test in
   `providers/sftp/tests/unit/sftp/hooks/test_sftp.py` blew up with:
   
   ```
   TypeError: 'coroutine' object does not support the asynchronous context 
manager protocol
   ```
   
   In real asyncssh, both `SSHClientConnection.start_sftp_client()` and
   `SFTPClient.open()` are decorated so a call returns an object that is
   both awaitable *and* async-context-manageable. The production code only
   uses the context-manager half. Override the auto-spec'd AsyncMocks with
   sync `MagicMock`s that return a context-manager mock with `__aenter__` /
   `__aexit__` configured.
   
   ## Test plan
   
   - [x] All 28 `TestSFTPHookAsync` tests in
         `providers/sftp/tests/unit/sftp/hooks/test_sftp.py` pass locally
         against `upstream/main`.
   - [x] `prek run` clean on the changed file.
   
   Blocking CI on unrelated PRs since #64465 merged — example failure:
   
https://github.com/apache/airflow/actions/runs/25638333348/job/75256444992?pr=65840
   (PR #65840 only touches `docs-theme`/breeze; the SFTP failures are
   purely fixture rot).
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Opus 4.7 (1M context)
   
   Generated-by: Claude Opus 4.7 (1M context) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
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]

Reply via email to