summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_regrtest.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-08-14 12:18:51 (GMT)
committerGitHub <noreply@github.com>2019-08-14 12:18:51 (GMT)
commitb0c8369c603633f445ccbb5ca7a8742145ff9eec (patch)
treede43af98636263000fcdcdb028d3302c89757478 /Lib/test/test_regrtest.py
parent6bccbe7dfb998af862a183f2c36f0d4603af2c29 (diff)
downloadcpython-b0c8369c603633f445ccbb5ca7a8742145ff9eec.zip
cpython-b0c8369c603633f445ccbb5ca7a8742145ff9eec.tar.gz
cpython-b0c8369c603633f445ccbb5ca7a8742145ff9eec.tar.bz2
bpo-37531: Fix regrtest timeout for subprocesses (GH-15072)
Co-Authored-By: Joannah Nanjekye <joannah.nanjekye@ibm.com>
Diffstat (limited to 'Lib/test/test_regrtest.py')
-rw-r--r--Lib/test/test_regrtest.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index fdab8c8..931f125 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -1154,6 +1154,33 @@ class ArgsTestCase(BaseTestCase):
env_changed=[testname],
fail_env_changed=True)
+ def test_multiprocessing_timeout(self):
+ code = textwrap.dedent(r"""
+ import time
+ import unittest
+ try:
+ import faulthandler
+ except ImportError:
+ faulthandler = None
+
+ class Tests(unittest.TestCase):
+ # test hangs and so should be stopped by the timeout
+ def test_sleep(self):
+ # we want to test regrtest multiprocessing timeout,
+ # not faulthandler timeout
+ if faulthandler is not None:
+ faulthandler.cancel_dump_traceback_later()
+
+ time.sleep(60 * 5)
+ """)
+ testname = self.create_test(code=code)
+
+ output = self.run_tests("-j2", "--timeout=1.0", testname, exitcode=2)
+ self.check_executed_tests(output, [testname],
+ failed=testname)
+ self.assertRegex(output,
+ re.compile('%s timed out' % testname, re.MULTILINE))
+
def test_unraisable_exc(self):
# --fail-env-changed must catch unraisable exception
code = textwrap.dedent(r"""