mirror of
https://github.com/espressif/esptool.git
synced 2025-10-14 02:43:11 +08:00
test: disable color in tests
This commit is contained in:
@@ -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"
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user