On Thu, 25 Jun 2009 13:42:05 -0700, holger krekel <hol...@merlinux.eu>  
wrote:

> On Thu, Jun 25, 2009 at 12:47 -0700, Sridhar Ratnakumar wrote:
>> In py.test, is there a way to suppress stdout at all?
>>
>> In my program, if a test fails .. py.test prints a huge amount of text
>> (that the program prints to stdout) .. and I had to scroll back a lot to
>> see the traceback. This is very inconvenient. In most case, I just want
>> to see the traceback along with locals values.
> yes, makes sense - i had this need myself as well, actually.
> I'd like to have this and other report customizations be
> doable through a --report option (and thus also through ENV
> vars and conftest.py settings).
> For now, as a kind of workaround, you could put the following lines
> into a conftest plugin:
>    # example content of conftest.py
>     import py
>    def pytest_runtest_call(__call__, item):
>         cap = py.io.StdCapture()
>         try:
>             return __call__.execute() # call all other hook  
> implementations
>         finally:
>             outerr = cap.reset() # forget about capture
> if you run your tests now, all capturing should be dropped.
> does it work for you and is the effect roughly what you want?

Yes, this does the trick for me (although I would probably modify the code  
to log stdout to a file insead).

Thanks.

-srid
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to