test: disable color in tests

This commit is contained in:
Peter Dragun
2025-06-05 12:24:04 +02:00
parent 89e8dd05b5
commit fbcaf22645
2 changed files with 19 additions and 2 deletions

View File

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

View File

@@ -154,6 +154,20 @@ class EfuseTestCase:
def _run_command(self, cmd, check_msg, ret_code):
try:
env = os.environ.copy()
# Comprehensive color disabling and terminal size control
env.update(
# NO_COLOR and COLUMNS should be already set from conftest.py;
# We set them here for completeness and to avoid any mismatch.
# The rest is required only for espefuse tests in some edge cases
# (e.g. GH actions, etc.)
{
"NO_COLOR": "1",
"COLUMNS": "120", # Set terminal width for help output
"LINES": "24", # Some terminal may not apply COLUMNS without LINES
"TERM": "dumb", # Force terminal to dumb mode
}
)
p = subprocess.Popen(
cmd.split(),
shell=False,
@@ -161,6 +175,7 @@ class EfuseTestCase:
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
env=env,
)
output, _ = p.communicate()
returncode = p.returncode