You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move the gi.require_version(...) GTK-version pins that currently live inline at the top of individual addon test files into each addon's tests/__init__.py, so the pin is declared once per addon and applied to
every test in that folder, on every launch path.
Why
Right now each GUI-touching test hand-rolls its own pin preamble. That has
three problems we've already been bitten by:
It's repeated. ~13 test files carry the same boilerplate; a change to
the contract (e.g. adding Pango) means editing every one.
tests/__init__.py runs first anyway. Python imports <Addon>/tests/__init__.py before any <Addon>/tests/test_*.py, so the
pin belongs there — it then covers a bare python3 -m unittest <Addon>.tests.<mod> run, not just runs under a specific harness.
Key constraint (addons-source-specific)
Addons are distributed individually, so the pin must be self-contained
in each addon's own tests/__init__.py — we cannot use a shared
repo-level helper module (it wouldn't ship with the addon). This differs from
the testbed-side approach in gramps-testbed#43,
which can use a shared helper. Here, each tests/__init__.py carries the
~6-line block directly.
What goes in tests/__init__.py
Mirror gramps/gen/constfunc.py (Gtk 3.0 and Gdk 3.0 together), pinning
silently — a failure here must not raise, or it aborts the whole package
import and every test errors instead of skipping cleanly:
"""Test package for <Addon>. Pins the GTK 3 stack before any test moduleimports a gramps GUI/plugin module (the import chain loads Gtk; on aGTK-4-default host an unpinned import binds the wrong version)."""try:
importgigi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
except (ImportError, ValueError):
# No PyGObject / GTK 3 here; the test modules guard their own imports# and skip cleanly.pass
Then in each test module: delete the gi.require_version(...) lines, but keep the existing try: import gramps ... except: raise SkipTest(...)
availability guard (that gates on whether gramps is importable at all, which
is still per-module). Template already in the wild: RepositoriesReport/tests/__init__.py (addons-source gramps-project#929) uses exactly this
silent-pin pattern.
Inventory (machine-generated on maintenance/gramps61 — verify each)
Test files with an inline require_version to migrate (most pin
Gtk+Gdk; confirm per file):
Several addons still lack tests/__init__.py (e.g. CalculateEstimatedDates, DataEntryGramplet, TMGimporter). Gary's PR #931 adds five
empty ones — those are the natural home; this issue fills them. Coordinate
so we don't conflict with Add __init__.py to all unittest folders gramps-project/addons-source#931 (let it land, then add content).
The PR 820 pipeline's run_addon_tests.py pins Pango/PangoCairo/Gtk
but notGdk, so today the inline Gdk pins are what protect tests
under the pipeline. Once the contract lives in tests/__init__.py this is
belt-and-suspenders; either way, fixing run_addon_tests.py to add Gdk is
the testbed-side counterpart (gramps-testbed#43).
Acceptance criteria
Every GUI-touching addon test folder has a tests/__init__.py pinning Gtk 3.0 + Gdk 3.0 (silently, no SkipTest from __init__).
No addon test module carries its own gi.require_version for the core GTK
stack (grep */tests/test_*.py for require_version → only false-positive
comments remain).
PluginManager's Gtk-only pin is resolved.
Each migrated addon's tests still pass via python3 -m unittest <Addon>.tests.<module> on both a Gdk-3-default and a Gdk-4-default
interpreter.
Goal
Move the
gi.require_version(...)GTK-version pins that currently liveinline at the top of individual addon test files into each addon's
tests/__init__.py, so the pin is declared once per addon and applied toevery test in that folder, on every launch path.
Why
Right now each GUI-touching test hand-rolls its own pin preamble. That has
three problems we've already been bitten by:
PluginManager/tests/test_info_empty_requires.pypins
Gtkbut notGdk— exactly the gap that made addons-sourceForm editor: guard save against mid-edit deletion of referenced objects (bug 11054) gramps-project/addons-source#926 warn-and-skip on a GTK-4-default host. One forgotten line per file is
a latent, environment-dependent failure.
the contract (e.g. adding
Pango) means editing every one.tests/__init__.pyruns first anyway. Python imports<Addon>/tests/__init__.pybefore any<Addon>/tests/test_*.py, so thepin belongs there — it then covers a bare
python3 -m unittest <Addon>.tests.<mod>run, not just runs under a specific harness.Key constraint (addons-source-specific)
Addons are distributed individually, so the pin must be self-contained
in each addon's own
tests/__init__.py— we cannot use a sharedrepo-level helper module (it wouldn't ship with the addon). This differs from
the testbed-side approach in
gramps-testbed#43,
which can use a shared helper. Here, each
tests/__init__.pycarries the~6-line block directly.
What goes in
tests/__init__.pyMirror
gramps/gen/constfunc.py(Gtk 3.0 and Gdk 3.0 together), pinningsilently — a failure here must not raise, or it aborts the whole package
import and every test errors instead of skipping cleanly:
Then in each test module: delete the
gi.require_version(...)lines, butkeep the existing
try: import gramps ... except: raise SkipTest(...)availability guard (that gates on whether gramps is importable at all, which
is still per-module). Template already in the wild:
RepositoriesReport/tests/__init__.py(addons-source gramps-project#929) uses exactly thissilent-pin pattern.
Inventory (machine-generated on
maintenance/gramps61— verify each)Test files with an inline
require_versionto migrate (most pinGtk+Gdk; confirm per file):
CalculateEstimatedDates/tests/test_calculate_estimated_dates.pyDataEntryGramplet/tests/test_data_entry_gramplet.pyImportMerge/tests/test_integration_importmerge.pyLifeLineChartView/tests/test_lifelinechart_tooltip_cache.pySourceReferences/tests/test_sourcereferences_imports.pySqlite/tests/test_sqlite.pySurnameMappingGramplet/tests/test_surnamemappinggramplet_imports.pyTMGimporter/tests/test_integration.py,TMGimporter/tests/test_libtmg.pyWebSearch/tests/test_filetable.pyWordleGramplet/tests/test_wordlegramplet_imports.pyPartial pin to fix while migrating (pins Gtk, missing Gdk):
PluginManager/tests/test_info_empty_requires.pyAssess whether these GUI-touching tests need the pin too (no pin today):
Form/tests/test_integration_form.pyFRWebConnectPack/tests/test_geneanet_url.pyPrerequisitesCheckerGramplet/tests/test_main_active_page_none.pyDependencies / sequencing
tests/__init__.py(e.g.CalculateEstimatedDates,DataEntryGramplet,TMGimporter). Gary's PR#931 adds five
empty ones — those are the natural home; this issue fills them. Coordinate
so we don't conflict with Add __init__.py to all unittest folders gramps-project/addons-source#931 (let it land, then add content).
run_addon_tests.pypinsPango/PangoCairo/Gtkbut not
Gdk, so today the inlineGdkpins are what protect testsunder the pipeline. Once the contract lives in
tests/__init__.pythis isbelt-and-suspenders; either way, fixing
run_addon_tests.pyto add Gdk isthe testbed-side counterpart (gramps-testbed#43).
Acceptance criteria
tests/__init__.pypinningGtk 3.0 + Gdk 3.0 (silently, no
SkipTestfrom__init__).gi.require_versionfor the core GTKstack (grep
*/tests/test_*.pyforrequire_version→ only false-positivecomments remain).
PluginManager's Gtk-only pin is resolved.python3 -m unittest <Addon>.tests.<module>on both a Gdk-3-default and a Gdk-4-defaultinterpreter.
References
tests/__init__.py).RepositoriesReport/tests/__init__.py(addons-source RepositoriesReport: don't pass wrong-typed handles to type-specific getters (crash on example.gramps) gramps-project/addons-source#929).gramps/gen/constfunc.py(Gtk+Gdk together);gramps/gui/grampsgui.py(launcher pin set).