diff options
author | Jay <74105438+weijay0804@users.noreply.github.com> | 2023-06-12 20:29:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-12 20:29:02 (GMT) |
commit | f0fb782ddb7208a59cfc38ec4bcbd8d1a81f8a58 (patch) | |
tree | f911c2581dd32e2631bd4a748823e185564e9779 /Lib/test/test_asyncio | |
parent | 9544948e7e2f288513137a62308e875dac086a18 (diff) | |
download | cpython-f0fb782ddb7208a59cfc38ec4bcbd8d1a81f8a58.zip cpython-f0fb782ddb7208a59cfc38ec4bcbd8d1a81f8a58.tar.gz cpython-f0fb782ddb7208a59cfc38ec4bcbd8d1a81f8a58.tar.bz2 |
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>
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 6e8a51c..4dfaff8 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -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(): |