Skip to content

Replace **kwargs with explicit parameters in test mocks#98

Merged
alexkroman merged 3 commits into
mainfrom
claude/gifted-sagan-v17nn9
Jun 12, 2026
Merged

Replace **kwargs with explicit parameters in test mocks#98
alexkroman merged 3 commits into
mainfrom
claude/gifted-sagan-v17nn9

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Replace catch-all **kwargs and **_kwargs parameters with explicit keyword-only parameters in test mock functions to improve type safety and clarity.

Summary

This change systematically updates test mock functions across the test suite to use explicit keyword-only parameters instead of catch-all **kwargs or **_kwargs. This improves code clarity, enables better type checking, and makes the expected function signatures more discoverable.

Key Changes

  • test_stream_command.py: Updated mock stream_audio functions to explicitly declare on_begin, on_turn, and on_termination parameters instead of **_kwargs
  • test_stream_session.py: Same pattern applied to stream session mocks
  • test_stream_llm.py: Updated LLM streaming mocks with explicit callback parameters
  • test_agent_command.py: Updated run_session mocks to explicitly declare renderer, player, mic, and config parameters
  • test_onboard_sections.py: Expanded _fake_run_init and _fake_launch to explicitly list all expected keyword arguments
  • test_update_check.py: Updated fake_get and fake_popen to use explicit parameters (headers, timeout, follow_redirects, stdout, stderr, start_new_session, env)
  • test_login.py: Refactored login result helpers to use explicit json_mode parameter
  • test_coding_agent.py: Updated subprocess mocks with explicit timeout parameter
  • test_deploy.py: Updated fake_confirm and fake_run with explicit parameters
  • test_macos_audio_source.py: Updated subprocess mock with explicit capture_output, text, and check parameters
  • test_stream_command_flags.py: Updated stream audio mock with explicit callback parameters
  • test_context.py: Updated login mock with explicit json_mode parameter
  • test_init_template_serve.py: Updated HTTP mock with explicit parameters
  • test_login_guards.py: Removed unused **_kwargs from login result helper
  • test_output.py: Updated status context manager mock with explicit message parameter
  • test_streaming_sources.py: Updated subprocess mock with explicit stdout and stderr parameters

Implementation Details

All changes maintain backward compatibility with the calling code while making the function signatures more explicit and type-safe. This pattern aligns with the project's emphasis on strict typing and clarity in test code.

https://claude.ai/code/session_01XVarv54ryA8Eo9zohCKx77

Replace trailing **kwargs catch-alls on monkeypatched doubles with the
full explicit signature of the boundary they stand in for (stream_audio,
agent run_session, run_login_flow, llm.run_chain, coding_agent.run,
subprocess.run/Popen, httpx.get, typer.confirm, run_init, launch_app,
Console.status), so a renamed/removed/typo'd kwarg at the call site
fails loudly with a TypeError instead of being silently swallowed.

Left intact, deliberately:
- delegating wrappers (httpx.Client/os.access) where the real callee
  enforces the signature
- fakes whose captured kwargs dict is itself the assertion subject
  (exact-set or absence asserts in test_telemetry/test_init_runner)
- never-called trackers whose tests assert zero invocations

https://claude.ai/code/session_01XVarv54ryA8Eo9zohCKx77
@alexkroman alexkroman enabled auto-merge (squash) June 12, 2026 03:46
@alexkroman alexkroman merged commit 3ce5933 into main Jun 12, 2026
12 checks passed
@alexkroman alexkroman deleted the claude/gifted-sagan-v17nn9 branch June 12, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants