Skip to content

Commit

Permalink
Fixed: Using the -j option to run tests in multiple processes
Browse files Browse the repository at this point in the history
  caused tests that used the multiprocessing package to hang
  (because the testrunner replaced sys.stdin with an unclosable
  object).
  • Loading branch information
Jim Fulton committed Jun 20, 2016
1 parent 44b7b53 commit 2384860
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,10 @@ zope.testrunner Changelog
4.5.1 (unreleased)
==================

- Nothing changed yet.
- Fixed: Using the ``-j`` option to run tests in multiple processes
caused tests that used the ``multiprocessing`` package to hang
(because the testrunner replaced ``sys.stdin`` with an unclosable
object).


4.5.0 (2016-05-02)
Expand Down
3 changes: 3 additions & 0 deletions src/zope/testrunner/runner.py
Expand Up @@ -959,3 +959,6 @@ def readline(self):
print('*'*70)
print()
return 'c\n'

def close(self):
pass
9 changes: 9 additions & 0 deletions src/zope/testrunner/tests/test_runner.py
Expand Up @@ -171,3 +171,12 @@ class ZZ(K1, K2, K3): pass
# Sorting by reverse MRO, as computed by Python's MRO algorithm,
# would put the layers in a different order: K3, K1, K2, ZZ.
# Does that matter? The class diagram is symmetric, so I think not.

def test_FakeInputContinueGenerator_close(self):
# multiprocessing (and likely other forkful frameworks want to
# close sys.stdin. The test runner replaces sys.stdin with a
# FakeInputContinueGenerator for some reason. It should be
# closeable.

f = runner.FakeInputContinueGenerator()
f.close()
2 changes: 1 addition & 1 deletion src/zope/testrunner/tests/testrunner-errors.txt
Expand Up @@ -724,7 +724,7 @@ Then run the tests:
>>> sys.argv = ('test --tests-pattern ^sampletests(f|_i)?$ --layer 1 '
... ).split()
>>> testrunner.run_internal(defaults)
... # doctest: +NORMALIZE_WHITESPACE
... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF
Test-module import failures:
<BLANKLINE>
Module: sample2.sampletests_i
Expand Down

0 comments on commit 2384860

Please sign in to comment.