Skip to content

Commit 2225400

Browse files
committed
add unit test for failing futures
1 parent e06eb55 commit 2225400

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/unit/standalone/test_batched.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ def test_batched_futures_duplicated(self):
3535
self.assertEqual(batched_futures(lst=lst, nested_skip_lst=batched_lst[:1], n=3), [2, 2, 2])
3636
self.assertEqual(batched_futures(lst=lst, nested_skip_lst=batched_lst[:2], n=3), [3, 3, 3])
3737

38+
def test_batched_futures(self):
39+
lst = []
40+
for i in range(10):
41+
f = Future()
42+
if i % 3 == 0:
43+
f.set_exception(ValueError(f"Error for {i}"))
44+
else:
45+
f.set_result(i)
46+
lst.append(f)
47+
batched_lst = [Future(), Future()]
48+
batched_lst[0].set_result([1, 2, 4])
49+
batched_lst[1].set_result([5, 7, 8])
50+
self.assertEqual(batched_futures(lst=lst, n=3, nested_skip_lst=set()), [1, 2, 4])
51+
self.assertEqual(batched_futures(lst=lst, nested_skip_lst=batched_lst[:1], n=3), [5, 7, 8])
52+
with self.assertRaises(ValueError):
53+
batched_futures(lst=lst, nested_skip_lst=batched_lst, n=3)
54+
3855
def test_batched_futures_not_finished(self):
3956
lst = []
4057
for _ in list(range(10)):

0 commit comments

Comments
 (0)