Merge lp://staging/~yellow/zope.testing/fix-tests into lp://staging/~launchpad/zope.testing/3.9.4-fork
Proposed by
Brad Crittenden
Status: | Merged |
---|---|
Approved by: | Gary Poster |
Approved revision: | 49 |
Merged at revision: | 44 |
Proposed branch: | lp://staging/~yellow/zope.testing/fix-tests |
Merge into: | lp://staging/~launchpad/zope.testing/3.9.4-fork |
Diff against target: |
1667 lines (+705/-753) 13 files modified
.bzrignore (+1/-0) setup.py (+1/-1) src/zope/testing/testrunner/formatter.py (+4/-0) src/zope/testing/testrunner/options.py (+8/-4) src/zope/testing/testrunner/runner.py (+55/-0) src/zope/testing/testrunner/test_subunit.py (+7/-7) src/zope/testing/testrunner/test_testrunner_subunit.py (+616/-0) src/zope/testing/testrunner/testrunner-debugging-layer-setup.test (+1/-0) src/zope/testing/testrunner/testrunner-layers-buff.txt (+1/-0) src/zope/testing/testrunner/testrunner-layers-ntd.txt (+1/-0) src/zope/testing/testrunner/testrunner-subunit-layer-setup-failures.txt (+0/-40) src/zope/testing/testrunner/testrunner-subunit.txt (+0/-686) src/zope/testing/testrunner/tests.py (+10/-15) |
To merge this branch: | bzr merge lp://staging/~yellow/zope.testing/fix-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gary Poster (community) | Approve | ||
Yellow Squad | code | Pending | |
Review via email: mp+111442@code.staging.launchpad.net |
Description of the change
Fix failing tests caused by bit rot and the most recent changes to include sys.stdout and sys.stderr in the subunit output.
The latter breakage was fixed by converting two subunit doctests to be unit tests instead. In addition to the morphing of the stdout and stderr streams that we are now doing, the doctest runner changes it too. That was one level too much to cleanly handle and using unit tests avoided the problem.
Updated to p15.
To post a comment you must log in.
Wow! Great work. Nice changes to the tests, and thank you for cleaning up the world.
I have two comments: one each about the most predictably commentable things in the MP.
(1) For get_real_stdout and friend, would you feel better and be able to remove that apologetic comment if the code looked like this instead?
___stdout = ___stderr = None
def get_real_stdout():
"""The canonical right place to get __stdout__."""
return ___stdout or sys.__stdout__
def get_real_stderr():
"""The canonical right place to get __stderr__."""
return ___stderr or sys.__stderr__
def set_stdout(new):
"""Set __stdout__ so that you can clean things up later.
Other code can get at the original value with get_real_stdout."""
global ___stdout
___stdout = sys.__stdout__
sys.__stdout__ = new
def set_stderr(new):
"""Set __stderr__ so that you can clean things up later.
Other code can get at the original value with get_real_stderr."""
global ___stderr
___stderr = sys.__stderr__
sys.__stderr__ = new
def reset_stdout():
global ___stdout
result = sys.__stdout__
sys.__stdout__ = ___stdout
___stdout = None
return result
def reset_stderr():
global ___stderr
result = sys.__stderr__
sys.__stderr__ = ___stderr
___stderr = None
return result
Maybe you want those to mess with stdout and stderr too.
Then, in testrunner. options. get_options, instead of directly mucking with __stderr__...
# If we are running in a subprocess then the test runner code will
sys. __stderr_ _ = sys.stderr = StringIO()
# use stderr as a communication channel back to the spawning
# process so we shouldn't touch it.
if '--resume-layer' not in sys.argv:
...we say "zope.testing. testrunner. set_stderr( StringIO( ))"
Similarly, when we set __stdout__ in doctests, we use the functions above, and then reset them using the functions.
The advantage is that we are not doing anything at __init__ time, and everything seems a bit cleaner to me. What do you think?
(2) For the new XXX in src/zope/ testing/ testrunner/ tests.py in which we disable the tests, please add a bug for the broken tests and mention the number. I think it's worth following the usual practice.
Thanks again!