From 2384860c9668f6cebb6f17837c71d8737ab85f1e Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Mon, 20 Jun 2016 19:26:59 -0400 Subject: [PATCH] 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). --- CHANGES.rst | 5 ++++- src/zope/testrunner/runner.py | 3 +++ src/zope/testrunner/tests/test_runner.py | 9 +++++++++ src/zope/testrunner/tests/testrunner-errors.txt | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ac0f634..f171e06 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) diff --git a/src/zope/testrunner/runner.py b/src/zope/testrunner/runner.py index ad86166..d443fe6 100644 --- a/src/zope/testrunner/runner.py +++ b/src/zope/testrunner/runner.py @@ -959,3 +959,6 @@ def readline(self): print('*'*70) print() return 'c\n' + + def close(self): + pass diff --git a/src/zope/testrunner/tests/test_runner.py b/src/zope/testrunner/tests/test_runner.py index 02216e5..810d612 100644 --- a/src/zope/testrunner/tests/test_runner.py +++ b/src/zope/testrunner/tests/test_runner.py @@ -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() diff --git a/src/zope/testrunner/tests/testrunner-errors.txt b/src/zope/testrunner/tests/testrunner-errors.txt index 0d98e91..bdc70c5 100644 --- a/src/zope/testrunner/tests/testrunner-errors.txt +++ b/src/zope/testrunner/tests/testrunner-errors.txt @@ -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: Module: sample2.sampletests_i