Skip to content

Commit c92e2fa

Browse files
committed
test eager start with default factory
1 parent 73a20a5 commit c92e2fa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Lib/test/test_asyncio/test_eager_task_factory.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,5 +523,24 @@ def tearDown(self):
523523
asyncio.current_task = asyncio.tasks.current_task = self._current_task
524524
return super().tearDown()
525525

526+
527+
class DefaultTaskFactoryEagerStart(test_utils.TestCase):
528+
def test_eager_start_true_with_default_factory(self):
529+
name = None
530+
531+
async def asyncfn():
532+
nonlocal name
533+
name = asyncio.current_task().get_name()
534+
535+
async def main():
536+
t = asyncio.get_running_loop().create_task(
537+
asyncfn(), eager_start=True, name="example"
538+
)
539+
self.assertTrue(t.done())
540+
self.assertEqual(name, "example")
541+
await t
542+
543+
asyncio.run(main(), loop_factory=asyncio.EventLoop)
544+
526545
if __name__ == '__main__':
527546
unittest.main()

0 commit comments

Comments
 (0)