diff --git a/pkgs/by-name/or/orca/fix-mock-typing.patch b/pkgs/by-name/or/orca/fix-mock-typing.patch new file mode 100644 index 000000000000..87a63ece07af --- /dev/null +++ b/pkgs/by-name/or/orca/fix-mock-typing.patch @@ -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") diff --git a/pkgs/by-name/or/orca/package.nix b/pkgs/by-name/or/orca/package.nix index bb7049eba218..4b738cb46d0d 100644 --- a/pkgs/by-name/or/orca/package.nix +++ b/pkgs/by-name/or/orca/package.nix @@ -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 = ''