feat: Small tweaks to test fixtures #704
Merged
allenporter merged 5 commits intoPython-roborock:mainfrom Dec 23, 2025
Merged
Conversation
These are improvements factored out of a large change to add more e2e tests for device manager.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test fixture reliability and maintainability by cleaning up test setup code and making test behavior more predictable. The changes focus on preventing test side effects, improving test output readability, and adding better warnings for test hygiene issues.
Key changes:
- Extracted
get_running_loop()function in production code to enable more precise mocking without affecting global event loop state - Modified MQTT fixture to only populate response buffers after client connection, ensuring request/response ordering in test logs
- Added proper task cancellation handling and warnings for unconsumed test responses
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| roborock/devices/local_channel.py | Extracted get_running_loop() helper function to enable targeted mocking |
| tests/devices/test_local_channel.py | Updated patch target to use the new get_running_loop() function instead of global asyncio.get_running_loop |
| tests/fixtures/local_async_fixtures.py | Updated patch target to use the new get_running_loop() function instead of global asyncio.get_running_loop |
| tests/fixtures/mqtt.py | Added client_connected flag and gated response population to ensure proper ordering in test logs |
| tests/fixtures/pahomqtt_fixtures.py | Converted assertions to warnings for unconsumed responses and changed fixture to generator for cleanup |
| tests/fixtures/aiomqtt_fixtures.py | Added proper handling of CancelledError in polling task and ensured task is awaited after cancellation |
| tests/mqtt/test_roborock_session.py | Removed unconsumed MQTT responses that would now trigger warnings |
| tests/e2e/snapshots/test_mqtt_session.ambr | Updated snapshots to reflect reordered MQTT request/response logging (connack now appears after connect) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
977e181 to
82c648e
Compare
Contributor
Author
|
This now contains a feat commit since I want to build a new release. |
Lash-L
approved these changes
Dec 23, 2025
Collaborator
Lash-L
left a comment
There was a problem hiding this comment.
looks good - just make sure that when you squash you change hte commit title, i don't think the descriptions will cause a bump
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.
Update the test fixtures with some cleanups pulled out of a larger PR: