From f5244eb4f50104245ab902f4cb5e27ca46c3d3f8 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Sat, 8 Aug 2026 19:12:14 -0400 Subject: [PATCH] Tests: an inherited NO_COLOR silently blinds every colour assertion Rich honours NO_COLOR by stripping colour while keeping attributes, so a shell that sets it (agent harnesses do) fails the suite spuriously. The autouse fixture now deletes it. Co-Authored-By: Claude Fable 5 --- tests/conftest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index e34a5c7..45b95a7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,6 +9,11 @@ Terminal (both chip-capable) or a bare CI shell (not) — and screen assertions not change with the developer's glass. ``MESHTERM_POWERLINE=0`` is the supported pin; the cached verdict is cleared around each test so no ordering leaks it. Powerline- specific tests pass explicit modes or monkeypatch the widget's own switch. + +``NO_COLOR`` is environmental the same way: Rich honours it by stripping colour while +keeping attributes, which silently voids every colour assertion in the suite (a shell +run by an agent harness sets it). The autouse fixture below deletes it, so the tests +always see the colours the app really emits. """ from __future__ import annotations @@ -40,6 +45,9 @@ def plain(rendered: Union[str, Iterable[str]]) -> str: @pytest.fixture(autouse=True) def _plain_path_rendering(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]: monkeypatch.setenv("MESHTERM_POWERLINE", "0") + # An inherited NO_COLOR makes Rich strip colour (attributes kept) and every colour + # assertion silently reads bare text — see the module docstring. + monkeypatch.delenv("NO_COLOR", raising=False) powerline_support.cache_clear() yield powerline_support.cache_clear()