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

Feature Request: --capture=hide to hide stdout/stderr from the terminal #1478

Closed
matthiasha opened this Issue Mar 23, 2016 · 5 comments

Comments

Projects
None yet
6 participants
@matthiasha
Contributor

matthiasha commented Mar 23, 2016

This code mimics Python code with lots of stdout output:

def test_test():
    print 'bla bla bla\n' * 10
    assert False, 'something failed'

Running pytest with --tb=short, I get the following output:

================= test session starts ==================
platform linux2 -- Python 2.7.9 -- py-1.4.31 -- pytest-2.6.4
plugins: 
collected 1 items

test_test.py F

======================= FAILURES =======================
______________________ test_test _______________________
test_test.py:5: in test_test
    assert False, 'something failed'
E   AssertionError: something failed
E   assert False
----------------- Captured stdout call -----------------
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla
bla bla bla

=============== 1 failed in 0.02 seconds ===============

It would be helpful if I could disable the sections "captured stdout/err call", e.g. with --capture=hide, especially as our code prints hundreds of lines usually. The additional information that --tb=short gives over --tb=line however is very useful for understanding where problems come from.

@The-Compiler

This comment has been minimized.

Member

The-Compiler commented Mar 23, 2016

FWIW, I think this sounds really useful. I often did some change which caused a lot of tests (which also print hundreds of lines each) to fail, and hiding the captured output would've given me a nicer overview of what could be going wrong.

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Mar 23, 2016

I agree it might be useful.

Currently though capture actually configures which capture method to use: no capture, file descriptor or sys. We probably should separate "capture method" from "how to display captured output" options, so I suggest we use another option for that. Also, I imagine we could also have the option of redirecting captured output to a file in addition to showing/hiding it.

@odarbelaeze

This comment has been minimized.

odarbelaeze commented Jul 23, 2017

It might be super useful for me, we test an application with lots of logging and it gets super tiring to find the test traceback under the captured stdout/stderr outputs.

@gwax

This comment has been minimized.

gwax commented Oct 25, 2017

In my ideal, there'd be an equivalent to --tb=no for captured output; something like --stdout=no

@feuillemorte

This comment has been minimized.

Member

feuillemorte commented Jan 31, 2018

Please, review:
#3176

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 6, 2018

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 8, 2018

feuillemorte added a commit to feuillemorte/pytest that referenced this issue Feb 9, 2018

nicoddemus added a commit that referenced this issue Feb 9, 2018

@nicoddemus nicoddemus closed this Feb 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment