Skip to content

Commit bd64a4b

Browse files
committed
logging: drop an unreachable guard in the stale-snapshot test
The key is asserted present just above and nothing removes it while the handler is alive, so the 'if key in cache' branch could never be False. Codecov counted it as a partial branch; removing it makes the file's patch coverage exact.
1 parent 1b945ce commit bd64a4b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎testing/logging/test_bound_proxy.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,10 +1071,11 @@ def test_stale_cache_entry_is_rejected_via_the_back_reference() -> None:
10711071
# ``other`` may or may not be cached under a different key; what must
10721072
# hold is that the original snapshot can no longer validate: its
10731073
# back-reference would not resolve to whichever handler looks it up.
1074-
if key in catching_logs._target_cache:
1075-
entry = catching_logs._target_cache[key]
1076-
assert entry.handler_ref is stale_ref
1077-
assert entry.handler_ref() is handler # still alive here
1074+
# The entry for ``handler`` is still present (asserted above and not
1075+
# evicted while ``handler`` is alive), so no guard is needed here.
1076+
entry = catching_logs._target_cache[key]
1077+
assert entry.handler_ref is stale_ref
1078+
assert entry.handler_ref() is handler # still alive here
10781079

10791080
# Once the handler is really gone, the back-reference resolves to nothing
10801081
# and the entry can never pass the ``handler_ref() is handler`` check.

0 commit comments

Comments
 (0)