Skip to content

test: spawn a dbus-daemon when no session bus is available#647

Merged
bdraco merged 1 commit into
mainfrom
macos-test-suite
May 15, 2026
Merged

test: spawn a dbus-daemon when no session bus is available#647
bdraco merged 1 commit into
mainfrom
macos-test-suite

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 15, 2026

Summary

  • Adds a session-scoped autouse fixture in tests/conftest.py that spawns a temporary dbus-daemon against a temp unix socket and exports DBUS_SESSION_BUS_ADDRESS.
  • No-ops when DBUS_SESSION_BUS_ADDRESS is already set, so Linux CI under dbus-run-session is unaffected.
  • Falls through silently when dbus-daemon isn't on PATH, so the existing failure mode is preserved.

Motivation

Running the suite locally on macOS currently fails at import time on ~40 integration tests:

dbus_fast.errors.InvalidAddressError: DBUS_SESSION_BUS_ADDRESS not set

Homebrew's dbus package provides a working dbus-daemon; this fixture just wires it in.

Test plan

  • poetry run pytest -q --no-cov on macOS with Homebrew dbus: 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.
  • Linux CI still passes (unaffected — fixture sees DBUS_SESSION_BUS_ADDRESS set by dbus-run-session).

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
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.53%. Comparing base (c6b4d7f) to head (815118f).

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.
📢 Have feedback on the report? Share it here.

🚀 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 15, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing macos-test-suite (815118f) with main (c6b4d7f)

Open in CodSpeed

@bdraco bdraco merged commit 3e06c0f into main May 15, 2026
26 checks passed
@bdraco bdraco deleted the macos-test-suite branch May 15, 2026 18:45
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.

1 participant