Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 71f73ca

Browse files
Issue #23713: Fixed fragility of test_imap_unordered_handle_iterable_exception.
Patch by Davin Potts.
1 parent 3bd66ab commit 71f73ca

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Lib/test/_test_multiprocessing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,17 +1799,23 @@ def test_imap_unordered_handle_iterable_exception(self):
17991799
it = self.pool.imap_unordered(sqr,
18001800
exception_throwing_generator(10, 3),
18011801
1)
1802+
expected_values = list(map(sqr, list(range(10))))
18021803
with self.assertRaises(SayWhenError):
18031804
# imap_unordered makes it difficult to anticipate the SayWhenError
18041805
for i in range(10):
1805-
self.assertEqual(next(it), i*i)
1806+
value = next(it)
1807+
self.assertIn(value, expected_values)
1808+
expected_values.remove(value)
18061809

18071810
it = self.pool.imap_unordered(sqr,
18081811
exception_throwing_generator(20, 7),
18091812
2)
1813+
expected_values = list(map(sqr, list(range(20))))
18101814
with self.assertRaises(SayWhenError):
18111815
for i in range(20):
1812-
self.assertEqual(next(it), i*i)
1816+
value = next(it)
1817+
self.assertIn(value, expected_values)
1818+
expected_values.remove(value)
18131819

18141820
def test_make_pool(self):
18151821
self.assertRaises(ValueError, multiprocessing.Pool, -1)

0 commit comments

Comments
 (0)