From dea2d70855ad21c591d360f859c46bf826edde51 Mon Sep 17 00:00:00 2001 From: Glen Beane <356266+gbeane@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:11:39 -0500 Subject: [PATCH] Run Qt tests offscreen so they don't open windows --- tests/conftest.py | 8 ++++++++ tests/ui/test_postprocessing_group.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..cb09c760 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,8 @@ +"""Shared test configuration for the application test suite.""" + +import os + +# Render Qt widgets offscreen so UI tests don't open windows and steal focus. Set before +# any test module creates a QApplication; override with e.g. QT_QPA_PLATFORM=cocoa to +# watch the widgets. +os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") diff --git a/tests/ui/test_postprocessing_group.py b/tests/ui/test_postprocessing_group.py index 4c3a05ef..b3e81bc3 100644 --- a/tests/ui/test_postprocessing_group.py +++ b/tests/ui/test_postprocessing_group.py @@ -218,7 +218,9 @@ def test_parameter_spinbox_is_sized_for_display_maximum() -> None: full_range_reference.setRange(1, _INT_MAX) width = spinbox.sizeHint().width() - assert width == display_reference.sizeHint().width() + # the hint subtracts two text widths that Qt rounds to whole pixels, so it can land + # one pixel off the reference + assert abs(width - display_reference.sizeHint().width()) <= 1 assert width < full_range_reference.sizeHint().width()