test: fix flaky macOS aiohttp connection refusal test

Merged
MA
13d ago
+28-15

The macOS unit job on main fails because test_connection_refused assumes a bound, non-listening socket immediately refuses connections. On the runner it instead produces a connection timeout, so the timed_out=False assertion fails. See the failing job.

Move connection-refusal coverage into the existing parameterized error-mapping test by injecting an aiohttp ClientConnectorError wrapping ECONNREFUSED. Preserve the sent=False and timed_out=False assertions and verify exception chaining for every error case. This changes only tests.

Validation:

  • Build SDK unit suite: 768 passed.
  • Full unit suite: 11,234 passed, 159 skipped, and 18 unrelated JavaScript failures with the shell's Node 18. All 18 failures passed when rerun with CI's Node 22 (19 tests passed in that rerun).
  • Full-run coverage: 79%.
  • Repository-wide Ruff lint and formatting checks passed.
  • uv run pyright reflex tests: zero errors or warnings.
  • Adversarial review: no actionable findings.