[py-dev] Capture of stdout

Jan Balster jan at balster.info
Thu May 12 17:15:49 CEST 2005


Hi Holger,

is there a simple way to get the captured output before
SimpleOutErrCapture.reset() is called?
Can we add a method for that?

Why would such a function be useful?

Example:
	Contents of TestModule
		
		print 'before test_function'
		
		def test_function():
			print 'test_function'			
			py.test.fail()			

		print 'after test_function'

If a Session instance can get the output of the parent collectors, the
report of test_function would be something like:

....

- - - - -  TestModule: recorded stdout - - - - - - - - -
before test_function

- - - - -  test_function: recorded stdout - - - - - - - - -
test_function


TerminalSession would print all output of the module, not just the part
before test_function was called.
In the current implementation of Terminal it's not necessary to fetch
the output 'in time', because all processing is done at the end.

I would prefer to get the output up to the moment when a test fails. Not
everything a parent collector prints. That's my opinion, and I don't
know if this feature is used in pypy testing.


Jan


More information about the py-dev mailing list