test: spawn a dbus-daemon when no session bus is available#647
Merged
Conversation
The Linux CI suite is launched under dbus-run-session, so a session bus is already available there. On macOS (or any host without an active session bus), the integration tests fail at import time with InvalidAddressError because DBUS_SESSION_BUS_ADDRESS is unset. Add a session-scoped autouse fixture in tests/conftest.py that: - no-ops if DBUS_SESSION_BUS_ADDRESS is already set (Linux CI under dbus-run-session, or any user-managed session bus). - starts dbus-daemon against a temp unix socket and exports the printed address when one is available on PATH (Homebrew dbus on macOS provides this). - yields silently when dbus-daemon isn't installed so tests that truly need a bus still surface the original error.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #647 +/- ##
=======================================
Coverage 88.53% 88.53%
=======================================
Files 29 29
Lines 3488 3488
Branches 602 602
=======================================
Hits 3088 3088
Misses 248 248
Partials 152 152 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
tests/conftest.pythat spawns a temporarydbus-daemonagainst a temp unix socket and exportsDBUS_SESSION_BUS_ADDRESS.DBUS_SESSION_BUS_ADDRESSis already set, so Linux CI underdbus-run-sessionis unaffected.dbus-daemonisn't onPATH, so the existing failure mode is preserved.Motivation
Running the suite locally on macOS currently fails at import time on ~40 integration tests:
Homebrew's
dbuspackage provides a workingdbus-daemon; this fixture just wires it in.Test plan
poetry run pytest -q --no-covon macOS with Homebrewdbus: 244 passed, 10 skipped (was 41 failed).DBUS_SESSION_BUS_ADDRESS=unix:path=/dev/null poetry run pytest tests/test_message_bus.py: passes; fixture detected the env var and didn't spawn.DBUS_SESSION_BUS_ADDRESSset bydbus-run-session).