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

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

Closed
matthiasha opened this issue Mar 23, 2016 · 5 comments
Closed
Labels
plugin: capture related to the capture builtin plugin type: enhancement new feature or API change, should be merged into features branch

Comments

@matthiasha
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

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
Copy link

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
Copy link

gwax commented Oct 25, 2017

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

@nicoddemus nicoddemus added plugin: capture related to the capture builtin plugin type: enhancement new feature or API change, should be merged into features branch labels Oct 26, 2017
@feuillemorte
Copy link
Contributor

Please, review:
#3176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: capture related to the capture builtin plugin type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

6 participants