Skip to content

Commit fbcaf22

Browse files
committed
test: disable color in tests
1 parent 89e8dd0 commit fbcaf22

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

test/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def need_to_install_package_err():
6363

6464

6565
@pytest.fixture(scope="session", autouse=True)
66-
def set_terminal_width():
67-
"""Make sure terminal width is set to 120 columns for consistent test output."""
66+
def set_terminal_properties():
67+
"""Make sure terminal width is set to 120 columns and color is disabled for
68+
consistent test output."""
6869
os.environ["COLUMNS"] = "120"
70+
os.environ["NO_COLOR"] = "1"

test/test_espefuse.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,28 @@ def espefuse_py(self, cmd, do_not_confirm=True, check_msg=None, ret_code=0):
154154

155155
def _run_command(self, cmd, check_msg, ret_code):
156156
try:
157+
env = os.environ.copy()
158+
# Comprehensive color disabling and terminal size control
159+
env.update(
160+
# NO_COLOR and COLUMNS should be already set from conftest.py;
161+
# We set them here for completeness and to avoid any mismatch.
162+
# The rest is required only for espefuse tests in some edge cases
163+
# (e.g. GH actions, etc.)
164+
{
165+
"NO_COLOR": "1",
166+
"COLUMNS": "120", # Set terminal width for help output
167+
"LINES": "24", # Some terminal may not apply COLUMNS without LINES
168+
"TERM": "dumb", # Force terminal to dumb mode
169+
}
170+
)
157171
p = subprocess.Popen(
158172
cmd.split(),
159173
shell=False,
160174
stdin=subprocess.PIPE,
161175
stdout=subprocess.PIPE,
162176
stderr=subprocess.STDOUT,
163177
universal_newlines=True,
178+
env=env,
164179
)
165180
output, _ = p.communicate()
166181
returncode = p.returncode

0 commit comments

Comments
 (0)