allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
730 stars 237 forks source link

ansi escape sequences formatting #806

Open delatrie opened 7 months ago

delatrie commented 7 months ago

Discussed in https://github.com/orgs/allure-framework/discussions/2485

Originally posted by **kuerbisbeule33** April 8, 2024 If I generate the Allure report, I notice that the raw ANSI escape sequences appear in the stdout section of the report (Execution -> Test Body -> Stdout). Consequently, I can see the escape sequences but not their formatting. Is there a way to replicate the same formatting (colors) in the Allure report as seen in the actual console output? ![raw_ansi_escapes](https://github.com/allure-framework/allure2/assets/85802951/50047c29-0a7a-4fa7-add2-5c80501a8d61)
sarzamas commented 6 months ago

vote for this bug!

same problem with color coded ANSI-colored strings in allure report... but I found it in attachment!

Monosnap Allure Report - Google Chrome 2024-05-18

in terminal same colored log strings look like this

Monosnap auto-tests

code to reproduce:

@pytest.fixture()
def log_delimiter(request):
    test_name = request.function.__name__
    test_title = f"{(' ' + test_name + ' '):-^79}"
    if request.config.option.color == 'yes':
        test_title = '\033[1m%s\033[0m' % test_title
    logger.info(f"{os.linesep}{test_title}")

Monosnap Allure Report - Google Chrome 2024-05-18_

Element: _pre class "attachment_text"

here is the attachment example with problematic ANSI-colored strings

432d516d-35f4-4650-812c-f4612fe782ca-attachment.txt