From 71ea92f3c2da200ee5ff0f7d5685836602609676 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 7 Nov 2026 08:27:33 +0100 Subject: [PATCH] gatelock tests: pin density in widget tests xvfb-run's 640x480 screen compacts the scale to 0.7 and clamps body and label to the same 11px floor. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWZd3smuxDGmEgXkYP8 --- gatelock/gatelock/tests/test_widgets.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gatelock/gatelock/tests/test_widgets.py b/gatelock/gatelock/tests/test_widgets.py index 4b3e4ce..3cb6f1e 100644 --- a/gatelock/gatelock/tests/test_widgets.py +++ b/gatelock/gatelock/tests/test_widgets.py @@ -16,6 +16,7 @@ from typing import TYPE_CHECKING import pytest +from gatelock import _density from gatelock._config import LockConfig from gatelock.widgets import ( DEFAULT_WRAP, @@ -50,6 +51,18 @@ def _font_px(widget: tk.Misc) -> int: return abs(int(tkfont.Font(font=widget.cget("font")).actual("size"))) +@pytest.fixture(autouse=True) +def _full_size_type_scale() -> Iterator[None]: + """Pin the density to 1.0 so type-size comparisons ignore the display. + + ``xvfb-run`` defaults to a 640x480 screen, which compacts the scale to 0.7 + and clamps both the body and label roles to the same 11px floor -- so + "primary reads larger" and "caption is smaller" became 8 vs 8. + """ + with _density.forced(1.0): + yield + + @pytest.fixture def root() -> Iterator[tk.Tk]: """A focused toplevel; Xvfb has no WM to assign X focus for us."""