Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions tests/unit/backends/test_cachekitio_transport_error_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,15 @@ def classify(exc: BaseException, **kwargs: object) -> None:


def test_interrupt_while_dropping_a_transport_failures_tracebacks_holds_no_exception(monkeypatch: pytest.MonkeyPatch) -> None:
"""An interrupt that lands in ``_send``'s walk over a transport failure's chain, the error already built."""
"""An interrupt that lands in ``_send``'s walk over a transport failure's chain, the error already built.

Only the transport handler's walk is patched: the interrupt branch uses the shared module's own walk.
"""
walk = backend_module._raised_during_request
walks: list[BaseException] = []

def interrupted(exc: BaseException, handled_before: BaseException | None) -> Iterator[BaseException]:
walks.append(exc)
chain = walk(exc, handled_before)
yield next(chain)
if len(walks) == 1: # the transport handler's walk, not the interrupt branch's
raise KeyboardInterrupt
yield from chain
yield next(walk(exc, handled_before))
raise KeyboardInterrupt

monkeypatch.setattr(backend_module, "_raised_during_request", interrupted)
backend = _faked(monkeypatch, lambda method, url, **kwargs: _make_request())
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_context_leak_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
def _isolated_stats_context():
"""Start each test with no stats context and restore the outer one after it.

A leak stays set in the pytest thread's context, so without this one leaking
A leak stays set in the pytest thread's context, so without it, one leaking
test would also fail every later test here that checks for None, and the
failure would point at the wrong test.
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_key_rotation_keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,7 @@ async def test_l2_read_raises_without_running_or_counting(self, monkeypatch, liv
for _ in range(3):
with pytest.raises(KeyringConfigurationError, match="Keyring configuration invalid"):
await _call(fn, 1)
# The sync wrapper has no outer `finally`: a raising exit that skips the
# stats reset leaks this call's stats into the caller's context.
# Every exit, this raise included, must restore the caller's stats context.
assert get_current_function_stats() is None

assert runs == []
Expand Down
Loading