mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-105331: Change asyncio.sleep
to raise `ValueError
for nan (#105641)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
9544948e7e
commit
f0fb782ddb
4 changed files with 24 additions and 0 deletions
|
@ -1609,6 +1609,21 @@ class BaseTaskTests:
|
|||
self.assertEqual(t.result(), 'yeah')
|
||||
self.assertAlmostEqual(0.1, loop.time())
|
||||
|
||||
def test_sleep_when_delay_is_nan(self):
|
||||
|
||||
def gen():
|
||||
yield
|
||||
|
||||
loop = self.new_test_loop(gen)
|
||||
|
||||
async def sleeper():
|
||||
await asyncio.sleep(float("nan"))
|
||||
|
||||
t = self.new_task(loop, sleeper())
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
loop.run_until_complete(t)
|
||||
|
||||
def test_sleep_cancel(self):
|
||||
|
||||
def gen():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue