Files
electron/script/dbus_mock.py
trop[bot] bffc44fae9 fix: linux test shutdown error "AttributeError: type object 'DBusTestCase' has no attribute 'stop_dbus'" (#51149)
stop_dbus() was removed on 2025-09-14 by
99c4800e9e

I think CI isn't seeing this yet because its image has an older version.

This patched script should work on old & new versions of python-dbusmock.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2026-04-19 00:52:58 -07:00

38 lines
944 B
Python

#!/usr/bin/env python3
import os
import subprocess
import sys
from dbusmock import DBusTestCase
from lib.config import is_verbose_mode
def stop():
if hasattr(DBusTestCase, 'stop_dbus'):
if DBusTestCase.system_bus_pid is not None:
DBusTestCase.stop_dbus(DBusTestCase.system_bus_pid)
if DBusTestCase.session_bus_pid is not None:
DBusTestCase.stop_dbus(DBusTestCase.session_bus_pid)
else:
DBusTestCase.tearDownClass()
def start():
with sys.stdout if is_verbose_mode() \
else open(os.devnull, 'w', encoding='utf-8') as log:
DBusTestCase.start_system_bus()
DBusTestCase.spawn_server_template('logind', None, log)
DBusTestCase.start_session_bus()
DBusTestCase.spawn_server_template('notification_daemon', None, log)
if __name__ == '__main__':
start()
try:
subprocess.check_call(sys.argv[1:])
finally:
stop()