[py-dev] Issue with py.test and stderr

Grig Gheorghiu grig at gheorghiu.net
Mon Jan 17 15:33:13 CET 2005


Armin,

Thanks for the response. I've noticed that messing with sys.__stderr__
is risky, so from now on I'll follow the "save and restore sys.stderr"
recipe.

BTW, would you guys be interested in some performance/scalability tests
for py.test? I was thinking about timing py.test on various
configurations that would involve things like:

- large number of files in a directory
- large number of sub-directories in a directory
- deeply nested directory tree

This would probably exercise the Collector part of py.test more than
other parts, but it would still be interesting in my opinion. What do
you think?

Thanks,

Grig

--- Armin Rigo <arigo at tunes.org> wrote:

> Hi Grig,
> 
> On Fri, Jan 14, 2005 at 11:56:48AM -0800, Grig Gheorghiu wrote:
> > I did run into a slight issue though. At some point I was
> instantiating
> > a class which was redirecting stderr to stdout under some
> > circumstances. The __del__ method of my class was resetting
> sys.stderr
> > to sys.__stderr__.
> 
> Note that there is support in py.test for clean setup/teardown
> semantics, i.e.
> instead of using __del__ (which is not guaranteed to run timely) you
> should
> save and restore sys.stderr in setup/teardown methods; e.g.:
> 
> def setup_module(mod):
>     mod.saved_stderr = sys.stderr
>     sys.stderr = ...something else...
> 
> def teardown_module(mod):
>     sys.stderr = mod.saved_stderr
> 
> 
> Armin
> 




More information about the Pytest-dev mailing list