Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(194785)

Delta Between Two Patch Sets: Lib/test/test_concurrent_futures.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 6 years ago
Right Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_complex.py ('k') | Lib/test/test_configparser.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import test.support 1 import test.support
2 2
3 # Skip tests if _multiprocessing wasn't built. 3 # Skip tests if _multiprocessing wasn't built.
4 test.support.import_module('_multiprocessing') 4 test.support.import_module('_multiprocessing')
5 # Skip tests if sem_open implementation is broken. 5 # Skip tests if sem_open implementation is broken.
6 test.support.import_module('multiprocessing.synchronize') 6 test.support.import_module('multiprocessing.synchronize')
7 # import threading after _multiprocessing to raise a more revelant error 7 # import threading after _multiprocessing to raise a more revelant error
8 # message: "No module named _multiprocessing". _multiprocessing is not compiled 8 # message: "No module named _multiprocessing". _multiprocessing is not compiled
9 # without thread support. 9 # without thread support.
10 test.support.import_module('threading') 10 test.support.import_module('threading')
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 future1], 342 future1],
343 timeout=0): 343 timeout=0):
344 completed_futures.add(future) 344 completed_futures.add(future)
345 except futures.TimeoutError: 345 except futures.TimeoutError:
346 pass 346 pass
347 347
348 self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE, 348 self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
349 EXCEPTION_FUTURE, 349 EXCEPTION_FUTURE,
350 SUCCESSFUL_FUTURE]), 350 SUCCESSFUL_FUTURE]),
351 completed_futures) 351 completed_futures)
352
353 def test_duplicate_futures(self):
354 # Issue 20367. Duplicate futures should not raise exceptions or give
355 # duplicate responses.
356 future1 = self.executor.submit(time.sleep, 2)
357 completed = [f for f in futures.as_completed([future1,future1])]
358 self.assertEqual(len(completed), 1)
352 359
353 360
354 class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.Tes tCase): 361 class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.Tes tCase):
355 pass 362 pass
356 363
357 364
358 class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.T estCase): 365 class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.T estCase):
359 pass 366 pass
360 367
361 368
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 675
669 @test.support.reap_threads 676 @test.support.reap_threads
670 def test_main(): 677 def test_main():
671 try: 678 try:
672 test.support.run_unittest(__name__) 679 test.support.run_unittest(__name__)
673 finally: 680 finally:
674 test.support.reap_children() 681 test.support.reap_children()
675 682
676 if __name__ == "__main__": 683 if __name__ == "__main__":
677 test_main() 684 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+