Skip to content

Commit a2c0f7e

Browse files
Add more tests.
1 parent 2d147a1 commit a2c0f7e

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

Lib/test/test_concurrent_futures/executor.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,19 @@ def test_map(self):
4848
list(map(pow, range(10), range(10))))
4949

5050
def test_map_exception(self):
51-
i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
52-
self.assertEqual(i.__next__(), (0, 1))
53-
self.assertEqual(i.__next__(), (0, 1))
51+
i = self.executor.map(divmod, [5, 5, 5, 5], [2, 3, 0, 5])
52+
self.assertEqual(i.__next__(), (2, 1))
53+
self.assertEqual(i.__next__(), (1, 2))
5454
self.assertRaises(ZeroDivisionError, i.__next__)
55-
self.assertEqual(i.__next__(), (0, 1))
55+
self.assertEqual(i.__next__(), (1, 0))
56+
self.assertRaises(StopIteration, i.__next__)
57+
self.assertRaises(StopIteration, i.__next__)
58+
59+
i = self.executor.map(divmod, [5, 5, 5, 5], [2, 0, 3, 5], chunksize=3)
60+
self.assertEqual(i.__next__(), (2, 1))
61+
self.assertRaises(ZeroDivisionError, i.__next__)
62+
self.assertEqual(i.__next__(), (1, 2))
63+
self.assertEqual(i.__next__(), (1, 0))
5664
self.assertRaises(StopIteration, i.__next__)
5765
self.assertRaises(StopIteration, i.__next__)
5866

@@ -71,6 +79,19 @@ def test_map_timeout(self):
7179

7280
self.assertEqual([None, None], results)
7381

82+
def test_map_close(self):
83+
i = self.executor.map(divmod, [5, 5, 5, 5], [2, 0, 3, 5])
84+
self.assertEqual(i.__next__(), (2, 1))
85+
i.close()
86+
self.assertRaises(StopIteration, i.__next__)
87+
self.assertRaises(StopIteration, i.__next__)
88+
89+
i = self.executor.map(divmod, [5, 5, 5, 5], [2, 0, 3, 5], chunksize=3)
90+
self.assertEqual(i.__next__(), (2, 1))
91+
i.close()
92+
self.assertRaises(StopIteration, i.__next__)
93+
self.assertRaises(StopIteration, i.__next__)
94+
7495
def test_shutdown_race_issue12456(self):
7596
# Issue #12456: race condition at shutdown where trying to post a
7697
# sentinel in the call queue blocks (the queue is full while processes

Lib/test/test_concurrent_futures/test_thread_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def log_n_wait(ident):
8080
fut = pool.submit(log_n_wait, ident="first")
8181
try:
8282
with contextlib.closing(
83-
pool.map(log_n_wait, ["second", "third"], timeout=1)
83+
pool.map(log_n_wait, ["second", "third"], timeout=0)
8484
) as gen:
8585
with self.assertRaises(TimeoutError):
8686
next(gen)

0 commit comments

Comments
 (0)