Merge lp://staging/~gmb/zope.testing/subunit-special into lp://staging/~launchpad/zope.testing/3.9.4-fork

Proposed by Graham Binns
Status: Merged
Merged at revision: 27
Proposed branch: lp://staging/~gmb/zope.testing/subunit-special
Merge into: lp://staging/~launchpad/zope.testing/3.9.4-fork
Diff against target: 0 lines
To merge this branch: bzr merge lp://staging/~gmb/zope.testing/subunit-special
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+106638@code.staging.launchpad.net

Description of the change

This branch makes the Zope.testing TestRunner redirect all in-test output to stderr when running with --subunit. This allows tests to spew nonsense to stdout without it interfering with the subunit stream (bug 996729).

This is handled by adding a wrapper around stdout which monkeypatches sys.stdout so that it points to sys.stderr upon instantiation. It cleans up after itself when closed (I'm not wholly certain that this isn't a landmine of sorts for later; opinions welcome).

The testing for this seems a little tortured; I get the feeling that I've added more test arguments than I really need to (to avoid futzing with the real stdout and stderr during a test run) but I can't really spot a way out of it. Again, please let me know if I've missed anything obvious.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good.

Re: "testing for this seems a little tortured": The best alternative I
can think of is to always use the real sys.stdout and put all of the
tests in a try/finally that puts sys.__stdout__ back in sys.stdout.
That way you can avoid the extra __init__ parameter and the two ifs but
still not have to worry about messing up sys.stdout.

review: Approve (code)
29. By Graham Binns

Updated tests to do less futzing with variables.

Preview Diff

Empty

Subscribers

People subscribed via source and target branches