Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape terminal escape sequences in output with test failures #5756

Closed
blueyed opened this issue Aug 17, 2019 · 0 comments
Closed

Escape terminal escape sequences in output with test failures #5756

blueyed opened this issue Aug 17, 2019 · 0 comments
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch

Comments

@blueyed
Copy link
Contributor

blueyed commented Aug 17, 2019

Given t.py:

def test_foo():
    haystack = "= \x1b[33m\x1b[1m1 skipped\x1b[0m\x1b[33m in"
    assert "skipped" not in haystack

Running pytest t.py:

>       assert "skipped" not in haystack
E       AssertionError: assert 'skipped' not in '= \x1b[33m\...m\x1b[33m in'
E         'skipped' is contained here:
E           = 1 skipped in
E         ?              +++++++

The "1 skipped in" is colored there.

This also applies to \r etc.

It is the reason for output like:

>       assert "1 passed in" in rest
\n'

(https://travis-ci.org/pytest-dev/pytest/jobs/516821221#L784)

I think it would be good to escape special characters sequences here. Likely \x1b, \r, \n, \r might be enough?

@Zac-HD Zac-HD added topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch labels Aug 20, 2019
@blueyed blueyed closed this as completed Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants