File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ def pt_filter_style(text: str | ANSI) -> str | ANSI:
7979
8080def pt_resolve_color_depth () -> ColorDepth :
8181 """Determine the prompt-toolkit ColorDepth based on NO_COLOR and ru.ALLOW_STYLE."""
82- if "NO_COLOR" in os .environ or ru .ALLOW_STYLE == ru .AllowStyle .NEVER :
82+ if os .environ . get ( "NO_COLOR" ) or ru .ALLOW_STYLE == ru .AllowStyle .NEVER :
8383 return ColorDepth .DEPTH_1_BIT
8484 return ColorDepth .TRUE_COLOR
8585
Original file line number Diff line number Diff line change @@ -100,15 +100,15 @@ def test_pt_filter_style_never() -> None:
100100
101101@with_ansi_style (ru .AllowStyle .ALWAYS )
102102def test_pt_resolve_color_depth_always (monkeypatch ) -> None :
103- # Ensure any host NO_COLOR environment variable doesn't affect the test
103+ # Clear NO_COLOR to ensure colors are not suppressed
104104 monkeypatch .delenv ("NO_COLOR" , raising = False )
105105 assert pt_resolve_color_depth () == ColorDepth .TRUE_COLOR
106106
107107
108108@with_ansi_style (ru .AllowStyle .TERMINAL )
109109def test_pt_resolve_color_depth_terminal (monkeypatch ) -> None :
110- # Ensure any host NO_COLOR environment variable doesn't affect the test
111- monkeypatch .delenv ("NO_COLOR" , raising = False )
110+ # Mock NO_COLOR to an empty string to ensure colors are not suppressed
111+ monkeypatch .setenv ("NO_COLOR" , "" )
112112 assert pt_resolve_color_depth () == ColorDepth .TRUE_COLOR
113113
114114
@@ -121,7 +121,7 @@ def test_pt_resolve_color_depth_never(monkeypatch) -> None:
121121
122122@with_ansi_style (ru .AllowStyle .ALWAYS )
123123def test_pt_resolve_color_depth_no_color (monkeypatch ) -> None :
124- # Mock NO_COLOR=1 to ensure colors are suppressed
124+ # Mock NO_COLOR to ensure colors are suppressed
125125 monkeypatch .setenv ("NO_COLOR" , "1" )
126126 assert pt_resolve_color_depth () == ColorDepth .DEPTH_1_BIT
127127
You can’t perform that action at this time.
0 commit comments