Skip to content

Commit 4a08061

Browse files
committed
pythongh-105331: Add test for asyncio.sleep() delay is nan
1 parent cc03137 commit 4a08061

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_asyncio/test_tasks.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,21 @@ async def sleeper(dt, arg):
16091609
self.assertEqual(t.result(), 'yeah')
16101610
self.assertAlmostEqual(0.1, loop.time())
16111611

1612+
def test_sleep_when_delay_is_nan(self):
1613+
1614+
def gen():
1615+
yield
1616+
1617+
loop = self.new_test_loop(gen)
1618+
1619+
async def sleeper():
1620+
await asyncio.sleep(float("nan"))
1621+
1622+
t = self.new_task(loop, sleeper())
1623+
1624+
with self.assertRaises(ValueError):
1625+
loop.run_until_complete(t)
1626+
16121627
def test_sleep_cancel(self):
16131628

16141629
def gen():

0 commit comments

Comments
 (0)