mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
tests/fprintd: Use a new bus for each test unit
When creating a new unit we used to get the system bus via Gio.bus_get_sync, however this has a singleton implementation, and so would always return the same connection, creating issues in tests when a new test suite is added because the newly got connection would be already closed. So, just manually create a new bus connection, also close the bus and cleanup the test bus in dbus.
This commit is contained in:
committed by
Bastien Nocera
parent
b2ad590891
commit
06480c7994
@ -1,5 +1,6 @@
|
||||
#! /usr/bin/env python3
|
||||
# Copyright © 2017, 2019 Red Hat, Inc
|
||||
# Copyright © 2020 Canonical Ltd
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@ -157,12 +158,19 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
||||
del os.environ['DBUS_SESSION_BUS_ADDRESS']
|
||||
except KeyError:
|
||||
pass
|
||||
os.environ['DBUS_SYSTEM_BUS_ADDRESS'] = cls.test_bus.get_bus_address()
|
||||
cls.dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
||||
addr = cls.test_bus.get_bus_address()
|
||||
os.environ['DBUS_SYSTEM_BUS_ADDRESS'] = addr
|
||||
cls.dbus = Gio.DBusConnection.new_for_address_sync(addr,
|
||||
Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION |
|
||||
Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT, None, None)
|
||||
assert cls.dbus.is_closed() == False
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.dbus.close()
|
||||
cls.test_bus.down()
|
||||
del cls.dbus
|
||||
del cls.test_bus
|
||||
shutil.rmtree(cls.tmpdir)
|
||||
dbusmock.DBusTestCase.tearDownClass()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user