fix(testing): TestKafkaBroker should mock a real tombstone too - #2939
Merged
Lancetnik merged 3 commits intoJul 15, 2026
Conversation
5 tasks
publish(None, ..., key=...) always ran through the codec and became b, never a true None. Real consumers see message.value() is None on a Kafka tombstone, same as the producer fix in 2932, but the test broker could never simulate that. Updated build_message in both confluent and kafka testing modules to skip the codec for message=None, mirroring 2932. Added tests for both drivers. Follows 2932 and 2933.
aradng
force-pushed
the
fix/confluent-testing-real-tombstone
branch
from
July 14, 2026 16:15
eaa5c85 to
d202931
Compare
Use the shared mock fixture and Context("message") idiom instead of an
asyncio.Queue, and assert synchronously after publish (the in-memory
TestBroker runs the handler inline), matching the other tests in these
files. Drops the now-unused typing.Any import.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lancetnik
approved these changes
Jul 15, 2026
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.
publish(None, topic, key=...) is supposed to simulate a real Kafka tombstone. Under TestKafkaBroker it never did. build_message ran None through the codec and got back b"", so message.value() was always bytes, never a true None.
This meant the tombstone path (message.value() is None) could never be exercised through the test broker at all, for confluent or kafka.
Fixed build_message in both faststream/confluent/testing.py and faststream/kafka/testing.py to skip the codec when message is None, same as the producer fix in #2932. Added a test for each driver confirming the mocked message now carries a real None value.
Follow up to #2932 and #2933.