[Python-checkins] cpython (merge 3.4 -> default): Issue #23713: Fixed fragility of test_imap_unordered_handle_iterable_exception.

serhiy.storchaka python-checkins at python.org
Thu Apr 23 10:37:20 CEST 2015


https://hg.python.org/cpython/rev/f60f65507d8e
changeset:   95783:f60f65507d8e
parent:      95780:2cc5650169fb
parent:      95782:0eb5968c15ad
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu Apr 23 11:36:40 2015 +0300
summary:
  Issue #23713: Fixed fragility of test_imap_unordered_handle_iterable_exception.
Patch by Davin Potts.

files:
  Lib/test/_test_multiprocessing.py |  10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)


diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1799,17 +1799,23 @@
         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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list