This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author asvetlov
Recipients asvetlov, mbussonn, njs, xtreak, yselivanov
Date 2019-05-22.11:31:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558524702.93.0.768041122422.issue37006@roundup.psfhosted.org>
In-reply-to
Content
Please keep in mind: not only asyncio can be used to execute async/await code.

For example, trio has completely different implementation but utilizes async functions as well.

Probably we need to customize it, maybe by inheriting AsyncioDocTestRunner from DocTestRunner base class.

Also, using asyncio.run() for every line is not a good idea.
asyncio.run() creates an new loop instance every time.
Thus, the following doesn't work:
>>> session = aiohttp.ClientSession()
>>> async with session.get(url) as resp:
...     text = await resp.text()

The session is bound to loop, but the loop is changed by the next line.
loop.run_until_complete() is not ideal too: it creates a new task every time.
In AsyncioTestCase (https://github.com/python/cpython/pull/13386) I'm avoiding this problem by keeping a long-running task for saving the execution context between setup/teardown and test itself.
History
Date User Action Args
2019-05-22 11:31:42asvetlovsetrecipients: + asvetlov, njs, yselivanov, mbussonn, xtreak
2019-05-22 11:31:42asvetlovsetmessageid: <1558524702.93.0.768041122422.issue37006@roundup.psfhosted.org>
2019-05-22 11:31:42asvetlovlinkissue37006 messages
2019-05-22 11:31:42asvetlovcreate