From 486d7f5e11a06dae0c3aa8dc9fe924aa94d50351 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 9 Mar 2024 22:19:49 +0000 Subject: [PATCH] Fix unit tests when run with Python 3.12 When running in command line mode, the Gedcom and ProGen importers were being run before the `gi.require_version` method, causing Gtk 4.0 to be incorrectly loaded. This caused some unit tests to fail. Fixes #13212. --- gramps/plugins/importer/importgedcom.py | 3 ++- gramps/plugins/importer/importprogen.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/importer/importgedcom.py b/gramps/plugins/importer/importgedcom.py index 03a0acd03a3..c468ced5720 100644 --- a/gramps/plugins/importer/importgedcom.py +++ b/gramps/plugins/importer/importgedcom.py @@ -39,7 +39,6 @@ _ = glocale.translation.gettext from gramps.gen.errors import DbError, GedcomError -from gramps.gui.glade import Glade from gramps.plugins.lib.libmixin import DbMixin from gramps.plugins.lib import libgedcom from gramps.gen.utils.libformatting import ImportInfo @@ -98,6 +97,8 @@ def importData(database, filename, user): return if not gramps and ansel and user.uistate: + from gramps.gui.glade import Glade + top = Glade() code = top.get_object("codeset") code.set_active(0) diff --git a/gramps/plugins/importer/importprogen.py b/gramps/plugins/importer/importprogen.py index 71ef1e55728..52189837525 100644 --- a/gramps/plugins/importer/importprogen.py +++ b/gramps/plugins/importer/importprogen.py @@ -26,6 +26,9 @@ # # ------------------------------------------------------------------------- import os, time +import gi + +gi.require_version("Gtk", "3.0") from gi.repository import Gtk, Gdk # ------------------------------------------------------------------------