orca: Enable tests

Initially, I wanted to verify that the required runtime dependencies are present
but the test environment will gladly pick them up from `buildInputs`
without them actually being recorded in the derivation for runtime.

The tests are still useful as a sanity check, though.

The three disabled tests will segfault in `_gtk_settings_get_screen`.
While that can be fixed by running the tests using `xvfb-run`, it them fails
on missing accessibility bus. Since it will be resolved in next orca version,
I am not bothering to replicate the integration test environment here.
This commit is contained in:
Jan Tojnar
2026-07-11 20:08:35 +02:00
parent da0d6c0f40
commit 358393045b
2 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
diff --git a/tests/unit_tests/test_dbus_service.py b/tests/unit_tests/test_dbus_service.py
index bf8cab8a7..0db3afd60 100644
--- a/tests/unit_tests/test_dbus_service.py
+++ b/tests/unit_tests/test_dbus_service.py
@@ -59,6 +59,7 @@ class TestDBusService:
external_modules = [
"gi",
"gi.repository",
+ "gi.repository.Atspi",
"dasbus",
"dasbus.connection",
"dasbus.error",
@@ -96,8 +97,16 @@ class TestDBusService:
"""Unpack the variant value."""
return self._value
- essential_modules["gi.repository"].GLib = test_context.Mock()
- essential_modules["gi.repository"].GLib.Variant = MockGLibVariant
+ gi_repository_mock = essential_modules["gi.repository"]
+ gi_repository_mock.GLib = test_context.Mock()
+ gi_repository_mock.GLib.Variant = MockGLibVariant
+
+ class Fake():
+ pass
+
+ atspi_mock = essential_modules["gi.repository.Atspi"]
+ atspi_mock.Accessible = Fake
+ gi_repository_mock.Atspi = atspi_mock
class MockPublishable:
"""Mock Publishable base class for inheritance."""
Taken from https://gitlab.gnome.org/GNOME/orca/-/commit/20340d2075a34721aa6af46507d02525f3eac5f5
diff --git a/src/orca/ax_utilities_application.py b/src/orca/ax_utilities_application.py
index 2edcabf11..d59b8ae9e 100644
--- a/src/orca/ax_utilities_application.py
+++ b/src/orca/ax_utilities_application.py
@@ -21,6 +21,7 @@
"""Utilities for accessible applications."""
+from __future__ import annotations
import gi
gi.require_version("Atspi", "2.0")
Taken from https://gitlab.gnome.org/GNOME/orca/-/commit/6c18ba002c6fac3fb80a10791b0daab6ea85f072
diff --git a/src/orca/ax_event_synthesizer.py b/src/orca/ax_event_synthesizer.py
index 4b999ef75..cb0f0e31a 100644
--- a/src/orca/ax_event_synthesizer.py
+++ b/src/orca/ax_event_synthesizer.py
@@ -22,6 +22,8 @@
"""Provides support for synthesizing accessible input events."""
+from __future__ import annotations
+
import gi
gi.require_version("Atspi", "2.0")

View File

@@ -55,6 +55,30 @@ python3.pkgs.buildPythonApplication (finalAttrs: {
];
})
# Fix tests on Python < 3.15
(fetchpatch {
url = "https://gitlab.gnome.org/GNOME/orca/-/commit/6c18ba002c6fac3fb80a10791b0daab6ea85f072.patch";
hash = "sha256-jTwVN0hPkead7PiVo/KEUrP04XU/05LXnXutvVmyecc=";
excludes = [
# These do not apply, fixed in fix-mock-typing.patch
"src/orca/ax_event_synthesizer.py"
"tests/unit_tests/test_flat_review_presenter.py"
];
})
# Fix more tests on Python < 3.15
(fetchpatch {
url = "https://gitlab.gnome.org/GNOME/orca/-/commit/0a1271f0d6ed6f6d73d41b227a9f6d84d994c154.patch";
hash = "sha256-ry8fmzUjtHR8/0UpB/zXuv6RYDS8z6fWRdb9eci6nLY=";
includes = [
"src/orca/sound.py"
];
})
# Fix more tests on Python < 3.15
# https://gitlab.gnome.org/GNOME/orca/-/work_items/729
./fix-mock-typing.patch
(replaceVars ./fix-paths.patch {
pgrep = "${procps}/bin/pgrep";
xkbcomp = "${xkbcomp}/bin/xkbcomp";
@@ -107,11 +131,32 @@ python3.pkgs.buildPythonApplication (finalAttrs: {
gst_all_1.gst-plugins-good
];
nativeCheckInputs = with python3.pkgs; [
pytest
];
checkInputs = with python3.pkgs; [
pytest-mock
];
postPatch = ''
# Disable broken tests
substituteInPlace tests/meson.build \
--replace-fail " 'unit_tests/test_preferences_grid_base.py'," "" \
--replace-fail " 'unit_tests/test_braille_presenter.py'," "" \
--replace-fail " 'unit_tests/test_profile_manager.py'," ""
'';
# Help GI find typelibs during Meson's configure step in cross builds
preConfigure = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
export GI_TYPELIB_PATH=${buildPackages.gtk3}/lib/girepository-1.0''${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}
'';
# `buildPythonPackage` uses `installCheckPhase` and leaves `checkPhase`
# empty. It renames `doCheck` from its arguments, but not `checkPhase`.
# See: https://github.com/NixOS/nixpkgs/issues/47390
installCheckPhase = "mesonCheckPhase";
dontWrapGApps = true; # Prevent double wrapping
preFixup = ''