Buffering test output

Buffer stdout and/or stderr during test execution, appending any output to the error reports of failed tests.

This allows you to use print for debugging in tests without making your test runs noisy.

This plugin implements startTest(), stopTest(), setTestOutcome(), outcomeDetail(), beforeInteraction() and afterInteraction() to manage capturing sys.stdout and/or sys.stderr into buffers, attaching the buffered output to test error report detail, and getting out of the way when other plugins want to talk to the user.

Configuration [output-buffer]

always-on
Default

False

Type

boolean

stderr
Default

False

Type

boolean

stdout
Default

True

Type

boolean

Sample configuration

The default configuration is equivalent to including the following in a unittest.cfg file.

[output-buffer]
always-on = False
stderr = False
stdout = True

Command-line options

-B DEFAULT, --output-buffer DEFAULT

Enable output buffer

Plugin class reference: OutputBufferPlugin

class nose2.plugins.buffer.OutputBufferPlugin(*args, **kwargs)[source]

Buffer output during test execution

afterInteraction(event)[source]

Start buffering again (does not clear buffers)

beforeInteraction(event)[source]

Stop buffering so users can see stdout

outcomeDetail(event)[source]

Add buffered output to event.extraDetail

setTestOutcome(event)[source]

Attach buffer(s) to event.metadata

startTest(event)[source]

Start buffering selected stream(s)

stopTest(event)[source]

Stop buffering