test: cover two guard branches and make the third pragma reason precise - #199
Merged
Merged
Conversation
lesnik512
force-pushed
the
chore/followups
branch
from
September 27, 2026 16:49
a7037ee to
caefdc9
Compare
Benchmark gate✅ gate passed
Gated (fails the build): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three
# pragma: no coversites had vague reasons. I checked each against the code:subscriber/usecase.py_run_with_reconnect,if client is None: return("defensive teardown race")TestOutboxBroker._patch_brokerputs back the broker's original client on exit, which isNonefor a broker built without an engine, and the loops read the client again on every iteration.test_run_with_reconnect_returns_when_client_is_gonechecks that a running loop with no client returns without opening resources or enteringinner.subscriber/config.pyOutboxSubscriberConfig.__post_init__,if parent_post_init is not None("defensive: base has none today")SubscriberUsecaseConfigno__post_init__. The guard is there so upstream init logic keeps running if faststream adds some.test_subscriber_config_runs_upstream_post_initadds a__post_init__toSubscriberUsecaseConfigwith monkeypatch and checks that registering a subscriber calls it.testing.py_sync_dispatch,if fake_row is None: return("defensive: feed just returned this id")feed()and the lookup. In batch publish, every row is fed before any is dispatched, so the handler of an earlier row does run first. That handler could remove a later row only by reaching into the fake: a lease-guarded delete needs a token the row does not have until its own dispatch, andcancel_timerneeds atimer_id, which batch rows never have.Evidence
client is Nonereturn, the loop hitsAttributeError: 'NoneType' object has no attribute 'engine'and goes into reconnect backoff. Withoutparent_post_init(), the mock is called 0 times.FakeOutboxClient(delete_with_lease,delete_batch_with_lease,cancel_timer) all require a matchingacquired_token, or atimer_idwith no lease.Checks (local)
just install: no lockfile changejust lint-ci: passjust test-ciagainst apostgres:17container (compose credentials, non-default host port): 631 passed, coverage 100.00%. The 89 integration tests ran; none were skipped.