tests: Mock logind’s Inhibit method

This is needed to allow gnome-shell to start up during its unit tests,
as it now calls `Inhibit` to make saving screen time information
race-free.

See
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3643#note_2367420.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4314>
This commit is contained in:
Philip Withnall 2025-03-03 12:48:37 +00:00
parent 0651563e3b
commit 6bd634e7ad

View File

@ -158,6 +158,11 @@ def GetSessionByPID(self, pid):
session_path = f'{MAIN_OBJ}/session/{self.preferred_session_id}'
return session_path
@dbus.service.method(MANAGER_IFACE, in_signature='ssss', out_signature='h')
def Inhibit(self, what, who, why, mode):
# Return an arbitrary FD
return os.open('/dev/null', os.O_RDONLY)
def create_session(self, host_bus):
session_id = None
seat_id = None