]> granicus.if.org Git - python/commitdiff
Issue #23713: Fixed fragility of test_imap_unordered_handle_iterable_exception.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 23 Apr 2015 08:35:59 +0000 (11:35 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 23 Apr 2015 08:35:59 +0000 (11:35 +0300)
Patch by Davin Potts.

Lib/test/_test_multiprocessing.py

index ff31e3669c17b4e054f7aaa27f421533a363b246..204d894ec6860ea5e86202c5ead1858bb88a3ecf 100644 (file)
@@ -1799,17 +1799,23 @@ class _TestPool(BaseTestCase):
         it = self.pool.imap_unordered(sqr,
                                       exception_throwing_generator(10, 3),
                                       1)
+        expected_values = list(map(sqr, list(range(10))))
         with self.assertRaises(SayWhenError):
             # imap_unordered makes it difficult to anticipate the SayWhenError
             for i in range(10):
-                self.assertEqual(next(it), i*i)
+                value = next(it)
+                self.assertIn(value, expected_values)
+                expected_values.remove(value)
 
         it = self.pool.imap_unordered(sqr,
                                       exception_throwing_generator(20, 7),
                                       2)
+        expected_values = list(map(sqr, list(range(20))))
         with self.assertRaises(SayWhenError):
             for i in range(20):
-                self.assertEqual(next(it), i*i)
+                value = next(it)
+                self.assertIn(value, expected_values)
+                expected_values.remove(value)
 
     def test_make_pool(self):
         self.assertRaises(ValueError, multiprocessing.Pool, -1)