Skip to content

Commit

Permalink
get rid of future iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 committed Jan 5, 2025
1 parent 2228e92 commit 82b905d
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 277 deletions.
54 changes: 27 additions & 27 deletions Lib/test/test_asyncio/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,33 +641,33 @@ def test_set_result_unless_cancelled(self):
futures._set_result_unless_cancelled(fut, 2)
self.assertTrue(fut.cancelled())

def test_future_stop_iteration_args(self):
fut = self._new_future(loop=self.loop)
fut.set_result((1, 2))
fi = fut.__iter__()
result = None
try:
fi.send(None)
except StopIteration as ex:
result = ex.args[0]
else:
self.fail('StopIteration was expected')
self.assertEqual(result, (1, 2))

def test_future_iter_throw(self):
fut = self._new_future(loop=self.loop)
fi = iter(fut)
with self.assertWarns(DeprecationWarning):
self.assertRaises(Exception, fi.throw, Exception, Exception("zebra"), None)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self.assertRaises(TypeError, fi.throw,
Exception, Exception("elephant"), 32)
self.assertRaises(TypeError, fi.throw,
Exception("elephant"), Exception("elephant"))
# https://github.com/python/cpython/issues/101326
self.assertRaises(ValueError, fi.throw, ValueError, None, None)
self.assertRaises(TypeError, fi.throw, list)
# def test_future_stop_iteration_args(self):
# fut = self._new_future(loop=self.loop)
# fut.set_result((1, 2))
# fi = fut.__iter__()
# result = None
# try:
# fi.send(None)
# except StopIteration as ex:
# result = ex.args[0]
# else:
# self.fail('StopIteration was expected')
# self.assertEqual(result, (1, 2))

# def test_future_iter_throw(self):
# fut = self._new_future(loop=self.loop)
# fi = iter(fut)
# with self.assertWarns(DeprecationWarning):
# self.assertRaises(Exception, fi.throw, Exception, Exception("zebra"), None)
# with warnings.catch_warnings():
# warnings.filterwarnings("ignore", category=DeprecationWarning)
# self.assertRaises(TypeError, fi.throw,
# Exception, Exception("elephant"), 32)
# self.assertRaises(TypeError, fi.throw,
# Exception("elephant"), Exception("elephant"))
# # https://github.com/python/cpython/issues/101326
# self.assertRaises(ValueError, fi.throw, ValueError, None, None)
# self.assertRaises(TypeError, fi.throw, list)

def test_future_del_collect(self):
class Evil:
Expand Down
Loading

0 comments on commit 82b905d

Please sign in to comment.