Skip to content

Commit 3892d33

Browse files
cliffhallclaude
andcommitted
test(fetch): keep the timeout tests from leaking FETCH_TIMEOUT_MS
delenv of an absent variable records no undo, so main()'s write to FETCH_TIMEOUT_MS outlived the test and changed later tests' default. Set it first so teardown removes it. Also retitle the characterization test that called the timeouts hard-coded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent fed94f8 commit 3892d33

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎src/fetch/tests/test_protocol.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,10 @@ async def test_guard_uses_the_real_resolver() -> None:
10081008
)
10091009

10101010

1011-
async def test_timeouts_are_hard_coded(web: FakeWeb) -> None:
1012-
# Characterizes #4448: the page fetch uses a fixed 30s timeout and the
1013-
# robots.txt fetch uses httpx's 5s default; neither is configurable.
1011+
async def test_default_timeouts(web: FakeWeb) -> None:
1012+
# With nothing configured the page fetch waits 30s and the robots.txt
1013+
# fetch uses httpx's 5s default. Only the page timeout is configurable
1014+
# (#4448; tests/test_timeout.py).
10141015
web.add(ROBOTS, plain("", status=404))
10151016
web.add(PAGE, plain("ok"))
10161017
async with connect() as (session, _):

‎src/fetch/tests/test_timeout.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838

3939
@pytest.fixture(autouse=True)
4040
def no_timeout_env(monkeypatch: pytest.MonkeyPatch) -> None:
41-
# A developer's own FETCH_TIMEOUT_MS must not leak into these tests, and
42-
# monkeypatch restores whatever main() writes to the variable.
43-
monkeypatch.delenv(TIMEOUT_ENV, raising=False)
41+
# A developer's own FETCH_TIMEOUT_MS must not leak into these tests, nor
42+
# what main() writes to it into later tests. setenv first: delenv of an
43+
# absent variable records no undo, so main()'s write would survive.
44+
monkeypatch.setenv(TIMEOUT_ENV, "")
45+
monkeypatch.delenv(TIMEOUT_ENV)
4446

4547

4648
def recording_page(seen: list[dict[str, Any]]) -> Any:

0 commit comments

Comments
 (0)