Repository navigation
Conversation
Add fixtures for a GRASS session and a wx.App, a test which imports every installed GUI module, and a test of the dialog generated from a tool interface. The tests skip when wxPython is not installed or no display is available. In the pytest workflow, install Xvfb with pytest-xvfb, the libraries wxPython needs (listed in apt_wxgui.txt, so that other workflows using apt.txt keep the smaller list), and the latest wxPython wheel for Ubuntu from its GitHub release. The wheel is installed with uv, because its metadata lack the local version in the file name, which pip rejects. The tests were written with the help of Claude Code.
added 6 commits
November 25, 2026 22:07
The wx.App fixture teardown called wx.App.ProcessIdle, which does not exist in wxPython (only wx.EventLoopBase has it). Remove it with the wx.SafeYield call: the destroyed windows are deleted by the wx cleanup at exit. Tests using the wx.App are marked needs_wx_app automatically and run in a separate pytest step on Ubuntu, macOS and Windows. With the wx.App in the process, GTK threads are running and fork() in other tests warns about possible deadlocks; the Xvfb display and GUI imports also stay out of the other tests. The other runs exclude these tests and disable pytest-xvfb. GUI tests without the wx.App still run with the others, in parallel unless marked needs_solo_run. Split the long wxPython release URL line for yamllint. Written with the help of Claude Code.
Run only the step with the tests which need the wx.App under xvfb-run, as the wxPython CI does, instead of using the pytest-xvfb plugin, which depends on the unmaintained PyVirtualDisplay. The other test runs no longer need to disable the plugin. Written with the help of Claude Code.
The step with the tests which need the wx.App runs only these tests, so skipping them all for a missing display would leave the step passing. Fail instead when the CI variable is set, as on GitHub Actions. Locally, the tests are still skipped without a display. Written with the help of Claude Code.
Describe the gui_session and wx_app fixtures, the needs_wx_app marker, and how to run the GUI tests with a virtual display. Written with the help of Claude Code.
The parallel run selected tests only by needs_solo_run, so a test using the wx.App without that marker ran there instead of in its own step. Written with the help of Claude Code.
The wx.App and global settings changed by the GUI modules, such as raise on error set by the animation tool, stay for the rest of the process. Written with the help of Claude Code.
The tests marked with needs_wx_app are excluded from the shared pytest argument files, so the CMake workflow needs its own step to run them. The workflow already installs wxPython from apt; apt_wxgui.txt adds xvfb for the virtual display. Written with the help of Claude Code.
echoix
marked this pull request as ready for review
November 27, 2026 01:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First basic GUI test on pytest. It tests that the interface creates the dialog correctly.
Starting as a draft to evaluate the approach first.
My goal here is to set up the plumbing correctly to have GUI tests, and Python-only non-GUI tests (but for code in the gui subfolder) to be handled correctly.
Description
gui/wxpython/conftest.py:gui_session, a GRASS session mirrored toos.environwith the GUI directory onsys.path(GUI modules are unloaded afterwards), andwx_app, awx.Appwhose windows are destroyed at the end of the session.g.regiondialog from its interface and checks the generated command.wx_appare markedneeds_wx_appautomatically. They run in their own pytest step in the pytest and CMake workflows on Ubuntu (underxvfb-run), and on macOS and Windows; the other pytest runs exclude them. GUI tests without thewx.Apprun with the other tests.wx_apptests are skipped locally and fail in CI, so that the step can't pass without running them.doc/development/testing.md, including running them separately from the other tests, since some global settings changed by the GUI modules stay for the rest of the process.Motivation and context
The GUI has no tests run in CI. The import test is cheap and catches broken imports.
The tests creating the
wx.Apprun in a separate process because onewx.Applives for the whole process, and its GTK threads makefork()in other tests warn about possible deadlocks (seen in the pygrass grid tests). The display and the GUI imports also stay out of the other tests.xvfb-runis used directly, as in the wxPython CI, instead of pytest-xvfb, which depends on the unmaintained PyVirtualDisplay.How has this been tested?
Locally on Ubuntu 24.04 with Python 3.13, wxPython 4.3.2 and a CMake build of GRASS:
xvfb-run: 222 passed, also with-n 2.wx_apptests; a GUI test without thewx.Appruns in the parallel run.CI=true.needs_solo_runtests of the repository in one process, including the GUI tests: passed.Possible follow-up: the dialog test could use
GUI(show=False), so that no window shows up on the macOS and Windows runners.Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
The tests and CI changes were written with the help of Claude Code.
Suggested squash commit message