Skip to content

Commit 3058b7d

Browse files
authored
bpo-33613: Fix test_semaphore_tracker signal tests when using -Werror (GH-9778)
Tests involving sending signals to the semaphore_tracker will not fail anymore due to the fact that running the test suite with -Werror propagates warnings as errors. Fix a missing assertion when the semaphore_tracker is expected to die.
1 parent d0bb5d7 commit 3058b7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,7 +4548,8 @@ def check_semaphore_tracker_death(self, signum, should_die):
45484548
if pid is not None:
45494549
os.kill(pid, signal.SIGKILL)
45504550
os.waitpid(pid, 0)
4551-
with warnings.catch_warnings(record=True) as all_warn:
4551+
with warnings.catch_warnings():
4552+
warnings.simplefilter("ignore")
45524553
_semaphore_tracker.ensure_running()
45534554
pid = _semaphore_tracker._pid
45544555

@@ -4557,6 +4558,7 @@ def check_semaphore_tracker_death(self, signum, should_die):
45574558

45584559
ctx = multiprocessing.get_context("spawn")
45594560
with warnings.catch_warnings(record=True) as all_warn:
4561+
warnings.simplefilter("always")
45604562
sem = ctx.Semaphore()
45614563
sem.acquire()
45624564
sem.release()
@@ -4569,7 +4571,7 @@ def check_semaphore_tracker_death(self, signum, should_die):
45694571
if should_die:
45704572
self.assertEqual(len(all_warn), 1)
45714573
the_warn = all_warn[0]
4572-
issubclass(the_warn.category, UserWarning)
4574+
self.assertTrue(issubclass(the_warn.category, UserWarning))
45734575
self.assertTrue("semaphore_tracker: process died"
45744576
in str(the_warn.message))
45754577
else:

0 commit comments

Comments
 (0)