Skip to content

Commit 84c9e5b

Browse files
committed
Fix unused import and make __notes__ test more robust
- Remove unused warnings import - Use getattr() to safely check for __notes__ attribute - Add assertion for notes existence before checking content
1 parent 75495cc commit 84c9e5b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_multiprocessing_forkserver/test_preload.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import multiprocessing
44
import multiprocessing.forkserver
55
import unittest
6-
import warnings
76

87

98
class TestForkserverPreload(unittest.TestCase):
@@ -86,7 +85,9 @@ def test_preload_on_error_fail_breaks_context(self):
8685
with self.assertRaises((EOFError, ConnectionError, BrokenPipeError)) as cm:
8786
p.start() # Exception raised here
8887
# Verify that the helpful note was added
89-
self.assertIn('Forkserver process may have crashed', str(cm.exception.__notes__[0]))
88+
notes = getattr(cm.exception, '__notes__', [])
89+
self.assertTrue(notes, "Expected exception to have __notes__")
90+
self.assertIn('Forkserver process may have crashed', notes[0])
9091
finally:
9192
# Ensure pipes are closed even if exception is raised
9293
w.close()

0 commit comments

Comments
 (0)