From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:21:51 +0000 (+0200) Subject: [3.11] gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) (#110659) X-Git-Tag: v3.11.7~208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46347d3caf92e773f99b301ab4de7d13c99e04e3;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) (#110659) gh-110647: Fix signal test_stress_modifying_handlers() (GH-110650) * cycle_handlers() now waits until at least one signal is received. * num_received_signals can be equal to num_sent_signals. (cherry picked from commit e07c37cd5212c9d13749b4d02a1d68e1efcba6cf) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index a00c7e539400..0f3343b10e4a 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1347,7 +1347,7 @@ class StressTest(unittest.TestCase): num_sent_signals += 1 def cycle_handlers(): - while num_sent_signals < 100: + while num_sent_signals < 100 or num_received_signals < 1: for i in range(20000): # Cycle between a Python-defined and a non-Python handler for handler in [custom_handler, signal.SIG_IGN]: @@ -1380,7 +1380,7 @@ class StressTest(unittest.TestCase): if not ignored: # Sanity check that some signals were received, but not all self.assertGreater(num_received_signals, 0) - self.assertLess(num_received_signals, num_sent_signals) + self.assertLessEqual(num_received_signals, num_sent_signals) finally: do_stop = True t.join() diff --git a/Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst b/Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst new file mode 100644 index 000000000000..00f38c844755 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-10-10-23-20-13.gh-issue-110647.jKG3sY.rst @@ -0,0 +1,2 @@ +Fix test_stress_modifying_handlers() of test_signal. Patch by Victor +Stinner.