From 09bfd9bdce574117ee3b16f91b34807564a1abdd Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Sun, 26 Apr 2026 10:57:21 -0700 Subject: [PATCH] fix(tests): hoist _executor_mod alias so async wedge tests pass under --cov MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Copilot Auto-fix in 5a8f42b4 addressed the duplicate-import lint by removing 'import claude_sdk_executor as _executor_mod' entirely, but the async wedge tests (test_execute_marks_wedge_*, test_execute_clears_wedge_*) still call _executor_mod._reset_sdk_wedge_for_test() etc. — so they failed with NameError once that line was removed. Restore the alias, but at the top of the file (alongside the other module- level imports) rather than at line 1248. The late-file binding was the proximate cause of the original CI failure: with --cov enabled (#1817), sys.settrace + the @pytest.mark.asyncio wrapper combination caused the late module-level binding to not be visible from inside the async test bodies, even though the binding existed at module-load time. Hoisting fixes that scope-resolution issue. Verified locally with the exact CI config (--cov-fail-under=86): 1280 passed, 2 xfailed — total coverage 90.25% 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- workspace/tests/test_claude_sdk_executor.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/workspace/tests/test_claude_sdk_executor.py b/workspace/tests/test_claude_sdk_executor.py index 6ad7d4be..7122fe98 100644 --- a/workspace/tests/test_claude_sdk_executor.py +++ b/workspace/tests/test_claude_sdk_executor.py @@ -30,6 +30,17 @@ from claude_sdk_executor import ( # noqa: E402 wedge_reason, ) +# Module alias used by the wedge tests below — they read +# `_executor_mod.` to make the module-state vs function-state +# distinction explicit at the call site, separate from the names +# imported above. Hoisted to the top-of-file imports because the late +# binding (originally at line ~1248) was invisible to @pytest.mark.asyncio +# wrappers under coverage instrumentation (--cov, added by #1817): +# sys.settrace + the asyncio wrapper combination caused a +# `NameError: name '_executor_mod' is not defined` on every async wedge +# test. Hoisting the alias fixes that scope-resolution issue. +import claude_sdk_executor as _executor_mod # noqa: E402 + # ---------- Helpers ----------