Skip to content

test(python): Add tests for python sdk#3432

Merged
hubcio merged 11 commits into
apache:masterfrom
slbotbm:python-testing
Jun 15, 2026
Merged

test(python): Add tests for python sdk#3432
hubcio merged 11 commits into
apache:masterfrom
slbotbm:python-testing

Conversation

@slbotbm

@slbotbm slbotbm commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Closes #3317
Relates to #

Rationale

The python sdk only had a few happy path tests. This PR adds extensive testing for the sdk. Also explicitly maps errors, replacing unwraps.

What changed?

  • added extensive tests, divided into files. Division was done to separate concerns.
  • removed all usage of unwrap in the the rust code.
  • moved code of iterator.rs into consumer.rs. No need for an extra file for a small amount of code.

Local Execution

  • Passed
  • Pre-commit hooks

AI Usage

If AI tools were used, please answer:

  1. Which tools? codex
  2. Scope of usage? code generation, investigation
  3. How did you verify the generated code works correctly? read through and reasoned about the code, executed on my machine
  4. Can you explain every line of the code if asked? Yes

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jun 7, 2026
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.26316% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.60%. Comparing base (8678ead) to head (005b588).

Files with missing lines Patch % Lines
foreign/python/src/consumer.rs 78.72% 10 Missing ⚠️
foreign/python/src/identifier.rs 71.42% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3432      +/-   ##
============================================
+ Coverage     74.57%   74.60%   +0.03%     
  Complexity      937      937              
============================================
  Files          1249     1248       -1     
  Lines        123564   123576      +12     
  Branches      99837    99840       +3     
============================================
+ Hits          92143    92190      +47     
+ Misses        28438    28401      -37     
- Partials       2983     2985       +2     
Components Coverage Δ
Rust Core 75.70% <ø> (-0.02%) ⬇️
Java SDK 58.57% <ø> (ø)
C# SDK 69.96% <ø> (+0.10%) ⬆️
Python SDK 88.88% <85.26%> (+7.82%) ⬆️
PHP SDK 83.57% <ø> (ø)
Node SDK 91.22% <ø> (ø)
Go SDK 40.25% <ø> (ø)
Files with missing lines Coverage Δ
foreign/python/src/client.rs 97.62% <100.00%> (+5.76%) ⬆️
foreign/python/src/lib.rs 100.00% <ø> (ø)
foreign/python/src/send_message.rs 96.77% <100.00%> (+0.47%) ⬆️
foreign/python/src/identifier.rs 77.77% <71.42%> (-2.23%) ⬇️
foreign/python/src/consumer.rs 77.94% <78.72%> (+16.52%) ⬆️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hubcio hubcio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple notes that don't land on lines this PR changed, so leaving them here:

consume_messages in src/consumer.rs still has four unwrap() calls (around lines 170, 192, 207, 213) that this PR didn't touch. the call_method0("wait").unwrap() plus the join-handle unwrap() form a reachable panic path - if the passed shutdown event object's wait isn't callable it panics across the FFI boundary instead of raising a clean TypeError, since pyo3 doesn't enforce the asyncio.Event | None stub annotation. so the description's "removed all usage of unwrap in the rust code" isn't quite right - client.rs, identifier.rs and send_message.rs are clean now, but consumer.rs isn't. either map these too or soften the claim.

Comment thread foreign/python/tests/test_consumer_group.py Outdated
Comment thread foreign/python/tests/test_consumer_group.py Outdated
Comment thread foreign/python/tests/test_stream.py
Comment thread foreign/python/tests/test_stream.py Outdated
Comment thread foreign/python/tests/test_topic.py
Comment thread foreign/python/tests/test_message_operations.py Outdated
Comment thread foreign/python/tests/test_consumer_group.py
Comment thread foreign/python/src/consumer.rs Outdated
Comment thread foreign/python/src/identifier.rs Outdated
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 9, 2026
@slbotbm

slbotbm commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Also removed the remaining unwraps from consumer.rs

@slbotbm

slbotbm commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 11, 2026
@hubcio hubcio merged commit 715313c into apache:master Jun 15, 2026
52 checks passed
@github-actions github-actions Bot removed the S-waiting-on-review PR is waiting on a reviewer label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand Python SDK test coverage

5 participants