1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From: =?utf-8?q?Lukas_M=C3=A4rdian?= <slyon@ubuntu.com>
Date: Wed, 8 Oct 2025 12:39:32 +0200
Subject: test:dbus: avoid dependency on dbus-launch (Closes: #1117099)
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1117099
Forwarded: https://github.com/canonical/netplan/pull/560
---
tests/netplan_dbus/test_dbus.py | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/tests/netplan_dbus/test_dbus.py b/tests/netplan_dbus/test_dbus.py
index c6411ce..8ad1141 100644
--- a/tests/netplan_dbus/test_dbus.py
+++ b/tests/netplan_dbus/test_dbus.py
@@ -60,15 +60,12 @@ class TestNetplanDBus(unittest.TestCase):
def _create_mock_system_bus(self):
env = {}
- output = subprocess.check_output(["dbus-launch"], env={})
- for s in output.decode("utf-8").split("\n"):
- if s == "":
- continue
- k, v = s.split("=", 1)
- env[k] = v
+ p = subprocess.Popen(["dbus-daemon", "--print-address=1", "--session"],
+ env={}, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ env['DBUS_SESSION_BUS_ADDRESS'] = p.stdout.readline().strip().decode("ascii")
# override system bus with the fake one
os.environ["DBUS_SYSTEM_BUS_ADDRESS"] = env["DBUS_SESSION_BUS_ADDRESS"]
- self.addCleanup(os.kill, int(env["DBUS_SESSION_BUS_PID"]), 15)
+ self.addCleanup(p.kill)
def _run_netplan_dbus_on_mock_bus(self):
# run netplan-dbus in a fake system bus
|