Skip to content

Commit 56ff306

Browse files
committed
Test that a rejected NaN keeps an armed timeout
1 parent da32179 commit 56ff306

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎Lib/test/test_asyncio/test_timeouts.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ async def f():
264264
await task
265265
self.assertFalse(cm.expired())
266266

267+
async def test_reschedule_nan_keeps_armed_timeout(self):
268+
with self.assertRaises(TimeoutError):
269+
async with asyncio.timeout(0) as cm:
270+
when = cm.when()
271+
handle = cm._timeout_handler
272+
with self.assertRaisesRegex(ValueError, "NaN"):
273+
cm.reschedule(float("nan"))
274+
self.assertEqual(cm.when(), when)
275+
self.assertIs(cm._timeout_handler, handle)
276+
self.assertFalse(handle.cancelled())
277+
await asyncio.sleep(0)
278+
267279
async def test_repr_active(self):
268280
async with asyncio.timeout(10) as cm:
269281
self.assertRegex(repr(cm), r"<Timeout \[active\] when=\d+\.\d*>")

0 commit comments

Comments
 (0)