trivial: drop some boilerplate setup code in the unit tests

Use dbusmock's start_system_bus() to start and tear down the system
bus.
This commit is contained in:
Mario Limonciello 2024-02-28 20:33:42 -06:00
parent 493818a7e2
commit b5cf270a20

View file

@ -99,21 +99,8 @@ class Tests(dbusmock.DBusTestCase):
os.environ["G_DEBUG"] = "fatal_warnings"
# set up a fake system D-BUS
cls.test_bus = Gio.TestDBus.new(Gio.TestDBusFlags.NONE)
cls.test_bus.up()
try:
del os.environ["DBUS_SESSION_BUS_ADDRESS"]
except KeyError:
pass
os.environ["DBUS_SYSTEM_BUS_ADDRESS"] = cls.test_bus.get_bus_address()
cls.start_system_bus()
cls.dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
cls.dbus_con = cls.get_dbus(True)
@classmethod
def tearDownClass(cls):
cls.test_bus.down()
dbusmock.DBusTestCase.tearDownClass()
def setUp(self):
"""Set up a local umockdev testbed.