Merge lp:~gmb/zope.testing/subunit-special into lp:~launchpad/zope.testing/3.9.4-fork
| Status: | Merged |
|---|---|
| Merged at revision: | 27 |
| Proposed branch: | lp:~gmb/zope.testing/subunit-special |
| Merge into: | lp:~launchpad/zope.testing/3.9.4-fork |
| Diff against target: | 0 lines |
| To merge this branch: | bzr merge lp:~gmb/zope.testing/subunit-special |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Benji York (community) | code | 2012-05-21 | Approve on 2012-05-21 |
|
Review via email:
|
|||
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.
- 29. By Graham Binns on 2012-05-21
-
Updated tests to do less futzing with variables.


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.