Skip to content

Commit

Permalink
Remove ANSI escape color codes from log output in Python tests (OpenV…
Browse files Browse the repository at this point in the history
…isualCloud#330)

Signed-off-by: Konstantin Ilichev <konstantin.ilichev@intel.com>
  • Loading branch information
ko80 committed Feb 11, 2025
1 parent d68d0b1 commit 3f10c88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/validation/Engine/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
from queue import Queue
from typing import Any, List
import re

import pytest
from pytest_check import check
Expand Down Expand Up @@ -85,10 +86,13 @@ def readproc(process: subprocess.Popen):
case_id = case_id[: case_id.rfind("(") - 1]
logfile = os.path.join(LOG_FOLDER, "latest", f"{case_id}.pid{process.pid}.log")

ansi_esc = re.compile(r'\x1b\[[0-9;]*m')

output = []
with open(logfile, "w") as file:
if process.stdout is not None:
for line in iter(process.stdout.readline, ""):
line = ansi_esc.sub('', line) # Remove ANSI escape color codes
output.append(line)
file.write(line)
return "".join(output)
Expand Down

0 comments on commit 3f10c88

Please sign in to comment.