Skip to content

Commit 2f98b76

Browse files
rmnvgclaude
andcommitted
Allow loopback in vcr_config so --block-network works on Windows
Windows has no AF_UNIX socketpair(), so socket.socketpair() falls back to connecting a real loopback socket. asyncio's ProactorEventLoop uses exactly that call to build its self-pipe, so pytest-recording's network guard (--block-network, set in addopts) makes asyncio.run() itself raise "Network is disabled" before any async test can run, failing the whole suite on setup rather than in the test bodies. allowed_hosts already matches VCR's own host allowlist mechanism, so letting 127.0.0.1 through here re-enables loop construction without weakening the guard: provider endpoints stay blocked, only loopback is let through. Fixes typesafe-ai#44. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e1d4cc9 commit 2f98b76

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎tests/conftest.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ def vcr_config() -> dict[str, Any]:
120120
VCR configuration passed to `VCR.use_cassettes`.
121121
"""
122122
return {
123+
# --block-network (see addopts) blocks every socket connect, which on Windows
124+
# takes the suite down before a single test runs: there the ProactorEventLoop
125+
# builds its self-pipe with socket.socketpair(), whose Windows fallback
126+
# connects to 127.0.0.1, so asyncio.run() itself raises "Network is disabled".
127+
# Loopback is the only host let back through; provider endpoints stay blocked.
128+
"allowed_hosts": ["127.0.0.1"],
123129
# The registered JSON serializer keeps HTTP bodies as nested objects, so the
124130
# cassette diffs like its payloads instead of escaped string literals.
125131
"serializer": "json",

0 commit comments

Comments
 (0)