Skip to content

Sync fork's maintenance/gramps60 with upstream (2026-05-08)#13

Merged
eduralph merged 22 commits into
maintenance/gramps60from
sync/upstream-maintenance-gramps60-2026-05-08
May 8, 2026
Merged

Sync fork's maintenance/gramps60 with upstream (2026-05-08)#13
eduralph merged 22 commits into
maintenance/gramps60from
sync/upstream-maintenance-gramps60-2026-05-08

Conversation

@eduralph

@eduralph eduralph commented May 8, 2026

Copy link
Copy Markdown
Owner

Summary

Forward-merges gramps-project/addons-source:maintenance/gramps60 (tip 6ce59270) into the fork's maintenance/gramps60 (tip 146b9c3e). Brings the fork in line with upstream while preserving the fork-only CI cherry-picks from #12 on top.

What this brings in

Upstream PR / commit What
gramps-project#833 (merged 2026-05-08) WebSearch: fix bare imports in test_filetable for dotted-path loading — the immediate trigger for this sync
gramps-project#821 + bug 11010 Form: detect empty definition files; warn on column-size mismatches; fix crash on malformed XML
gramps-project#826 + follow-ups ImportMerge: fix AttributeError when adding/merging Tag objects, plus the rewrite-as-unittest follow-ups (apply Black, type hints, integration-test refactor, Gtk 3.0 pin)
(multiple) TMGimporter integration-test refactors

Fork-only commits preserved

The merge keeps the fork's two CI-only commits on top of the merge result:

  • f0cf1a48 CI: add shell: bash to unit-test-linux + integration-test steps
  • a99b83a4 CI: split OS-specific addon tests via filename convention

These are cherry-picks of upstream PR gramps-project#820's 28febdcd and 715e71dd. Once gramps-project#820 lands upstream, a future sync makes them redundant in history but produces no merge conflict (trees are equivalent).

Verification

Ran the testbed's local addon-unit suite against the merged tree:

$ ./scripts/ubuntu/run-addon-unit.sh WebSearch
Ran 28 tests in 0.017s
OK

$ ./scripts/ubuntu/run-addon-unit.sh TMGimporter
Ran 175 tests in 9.011s
OK

Spot-check on the workflow file post-merge to confirm fork's CI fixes survived intact:

Check Expected Actual
shell: bash step directives in .github/workflows/ci.yml 4 4 ✓
test_(linux|windows)_* skip-rule lines 2 2 ✓
WebSearch test_filetable.py has sys.path.insert prologue from gramps-project#833 yes yes ✓

Expected effect on fork CI

Once merged, the next CI run on maintenance/gramps60 should clear:

  • Unit Tests (Linux)WebSearch.tests.test_filetable now imports cleanly. With TMGimporter (175) + WebSearch (28) + linux_libtmg subset, expect green.
  • Integration Tests (Gramps) — fork inherits the upstream Form/ImportMerge unittest improvements.

Remaining red on this branch (separate follow-ups, all continue-on-error: true):

🤖 Generated with Claude Code

hgohel and others added 22 commits April 21, 2026 09:18
The argument `label` to Gtk.Label must be of type string. In recent versions of Python and/or PyGObject, this check has become stricter and as a result is throwing an exception instead of silently converting to a string. So now we explicitly convert to string.

Fixes #14181
… (bug 0012387)

The settings submenu builder appended the same SeparatorMenuItem twice,
which GTK rejected with "Can't set a parent on widget which has a parent".
The corrupt parent linkage caused a segfault when the previous menu was
garbage-collected on the next right-click. Removing the stray duplicate
append fixes all four context-menu paths (background canvas, person,
relation, missing parent) and silences the related GTK_IS_WIDGET
assertion warnings. Also resolves duplicate report 0013463.
…pen (bug 0012691)

Clicking Add (or Save after a dirty edit) when no tree was loaded
raised AttributeError: 'DummyDb' object has no attribute 'get_undodb'
from DbTxn. Guard both mutating callbacks on dbstate.is_open() and
surface a clear ErrorDialog instead.

Add unit tests for the closed-db guards, pre-existing input guards,
and .gpr.py registration metadata so future refactors can't silently
break the bug-12691 fix.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Gramps' own test suite uses unittest, not pytest, so addon tests that
ship alongside the codebase should follow the same convention to stay
contributable upstream without rewriting.

Replace pytest fixtures, monkeypatch, and module-level test functions
with unittest.TestCase classes and mock.patch.object. Guard the
module-level addon import with a try/except that raises SkipTest so
collection is quiet on environments without the GUI stack, and pin
Gtk to 3.0 before gramps imports to avoid the GTK4 fallback crash on
Gtk.IconSize.MENU.
…odule

When unittest loads this file as DataEntryGramplet.tests.test_..., the
outer DataEntryGramplet is already a namespace package in sys.modules,
so `from DataEntryGramplet import DataEntryGramplet` binds the submodule
and DataEntryGramplet.NO_REL (class attr) raises AttributeError. Fix by
importing the class via its fully-qualified path.
…n (bug 0007898)

probably_alive_range raises DatabaseError when it detects loops in
ancestor or descendant chains. Previously this propagated out of the
removal, selection, and apply loops and tore down the entire tool,
leaving signals disabled and the progress dialog stuck open.

Wrap each per-person iteration with try/except so a single bad record
is logged and skipped, and add outer try/finally blocks so signals are
re-enabled and the progress dialog is closed even on unexpected
failures. Surface a "Skipped N people due to errors" message to the
user when any rows were skipped.

Add unit tests covering get_modifier branches, calc_estimates happy
path, DatabaseError propagation from calc_estimates, and .gpr.py
registration metadata. The addon module is loaded lazily inside a
fixture so pytest collection succeeds even when the GUI stack cannot
import.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Gramps' own test suite uses unittest, not pytest, so addon tests that
ship alongside the codebase should follow the same convention to stay
contributable upstream without rewriting.

Replace pytest fixtures, monkeypatch, and pytest.raises with
unittest.TestCase, mock.patch.object, and assertRaisesRegex. Guard the
module-level addon import with a try/except that raises SkipTest so
collection is quiet on environments without the GUI stack, and pin Gtk
to 3.0 before gramps imports to avoid the GTK4 fallback crash on
Gtk.IconSize.MENU.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Tag is a table object without a gramps_id field, so the generic
has_<obj_type>_gramps_id / find_next_<obj_type>_gramps_id lookups in
do_commits raised AttributeError when the user selected Add on a Tag
row. Guard both the S_ADD and S_DIFFERS GID-conflict blocks so they
skip Tag.

Adds integration tests covering both branches; verified they fail
without the guard and pass with it.

Fixes bug 0014056

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
On systems with both GTK3 and GTK4 installed, PyGObject defaults to
GTK4, and importing ImportMerge pulls in gramps.gui which crashes on
Gtk.IconSize.MENU (a GTK3-only enum). Mirror the pin that
gramps.grampsapp performs at startup so reviewers can run the test
without environment tweaks.
AGENTS.md requires the unittest framework for tests. Convert the
pytest-based integration test (fixtures + assert statements) to a
unittest.TestCase with setUp/tearDown and self.assert* calls. GTK
availability is now checked with a module-level try/except raising
unittest.SkipTest, which also makes the separate GTK-pin step
redundant (still applied here before the gramps import).
Addresses AGENTS.md rule requiring Black-formatted Python. Collapses
three multi-line function calls that fit on a single line.
Addresses AGENTS.md requirements:
- Type hints on all helpers and test methods using Python 3.10+
  syntax (``X | None``, ``tuple[X, Y]``).
- Sphinx-style ``:param:`` / ``:returns:`` docstring markers on the
  helper functions.
- ``# ------`` class-header divider above the TestCase so it's easy
  to locate.

No behavioural change.
A family section whose title lacked the expected 'X/Y' separator caused
a ValueError: not enough values to unpack when the form editor opened,
crashing the Forms gramplet. The underlying issue was that the addon
trusted the XML definitions and had no schema validation or user-facing
error reporting for broken files.

Split the validation out of form.py into a pure-Python form_validator
module (no GTK/Gramps imports) so it can be unit-tested without a GUI.
The Form loader now:

* parses each file defensively (ExpatError -> ErrorDialog),
* runs the validator before loading (invalid files -> ErrorDialog with
  the file path, offending form id, and the rule that failed),
* skips any <form> element that fails validation while still loading
  sibling well-formed forms from the same file.

split_family_title() in form_validator belt-and-braces the FamilySection
constructor so a missing separator no longer raises, even if validation
is bypassed.

Also adds diagnostic logging:

* INFO log of forms loaded per file,
* DEBUG trace of each file parsed and each form id loaded/skipped,
* DEBUG when EditForm opens (event/citation handles),
* WARNING in FamilySection if its title lacks 'X/Y'.

Tests:

* Form/tests/test_form_validator.py -- 32 pure-Python unit tests,
  covers split_family_title, every validation branch, parse_and_validate
  file handling, and a sanity check that every shipped form_*.xml passes
  validation.
* Form/tests/test_integration_form.py -- unittest integration tests that
  patch ErrorDialog to verify the loader surfaces syntax errors, invalid
  family titles, missing role, and invalid section types; partially
  broken files still load their valid forms; shipped files trigger no
  dialogs.

Partially addresses bug 0011010 (request for user error dialog for
unsupported elements) by covering its core ask: clear errors for
invalid section types, missing/empty role, missing/empty type, and XML
syntax errors.

Fixes #11707.
Refs #11010.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…s (bug 0011010)

A form definition file whose <forms> root contained no <form> elements
used to load silently — the loader iterated zero <form> children and
returned, leaving the user with no feedback.  validate_form_dom now
reports this as an error so the ErrorDialog wiring added for bug 11707
surfaces the problem on load.

get_form_warnings is a new non-fatal check for sections whose <column>
<size> values do not sum to 100.  78 shipped definition files violate
this rule today without breaking rendering (the size field is parsed
but never read by the layout code), so treating it as an error would
flag correctly-working forms.  The loader logs the warnings via
LOG.warning instead, making authoring mistakes in user-authored
custom.xml files diagnosable without harassing users of the built-in
forms.

Unit coverage: rejected empty <forms>, forms-root-with-only-comments,
and every branch of the sized-column check (no columns, no sizes,
summing to 100, summing to other totals, partial sizing, independent
of errors, multiple sections).  Integration coverage: empty-forms
triggers ErrorDialog; size mismatch is logged but does not block the
form from loading.  Tests use stdlib unittest to match Gramps' own
conventions.
`WebSearch/tests/test_filetable.py` imports `models`, `constants` and
`db_file_table` without a package prefix. Those resolve only when
`WebSearch/` itself is on sys.path — i.e. when the test is loaded via
`unittest discover` from inside `tests/`. Under the dotted-path form
that addons-source's own ci.yml uses (`python3 -m unittest
WebSearch.tests.test_filetable` from the addons-source root), the
imports look for a top-level `models` module and the test fails to
load:

    ImportError: Failed to import test module: test_filetable
    ModuleNotFoundError: No module named 'models'

Add the same `sys.path.insert(0, …parent dir…)` prologue that
TMGimporter and Form already use for the same pattern, so the test
loads under either form. No behavioural change beyond the imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Brings in everything upstream has merged since the fork's last sync,
including:
- WebSearch: fix bare imports in test_filetable (gramps-project#833, our patch)
- Form: detect empty definition files and warn on column-size
  mismatches (bug 0011010)
- Form: fix crash and surface clear errors for malformed XML (gramps-project#821)
- ImportMerge: fix AttributeError when adding/merging Tag objects
  (gramps-project#826) — including its rewrite-as-unittest follow-ups
- TMGimporter: integration test refactors

Fork retains its two CI-only commits (28febdc shell:bash, 715e71d
OS-split — present here as cherry-picks f0cf1a4 and a99b83a from
PR #12) on top of the merge. Once upstream PR gramps-project#820 lands, those
become redundant and a future sync makes them no-ops.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eduralph eduralph merged commit 7abb603 into maintenance/gramps60 May 8, 2026
3 of 7 checks passed
@eduralph eduralph deleted the sync/upstream-maintenance-gramps60-2026-05-08 branch May 8, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants