[issue37006] Add top level await statement support for doctest
Karthikeyan Singaravelan
report at bugs.python.org
Wed May 22 07:56:31 EDT 2019
Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:
I tried using AsyncioDocTestRunner that inherits from DocTestRunner and most of the current DocTestRunner is synchronous and the execution happens in __run that seems to cause problem due to name mangling inheriting and changing it. Also python -m doctest by default uses testmod/testfile that use DocTestRunner so I thought to change DocTestRunner would be simpler and existing code can use added doctest flag without changing runner.
To be little more clear by each line I meant each example. So in below "async with session.get(url) as resp:\n text = await resp.text()" counts as a single example whose code object is evaluated in asyncio.run which I said as per line by mistake.
>>> async with session.get(url) as resp:
... text = await resp.text()
Your concerns are reasonable about asyncio.run per example seem to be over kill and might not work in few cases. I also didn't think about trio. I will look into those. Thanks for the pointers.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37006>
_______________________________________
More information about the Python-bugs-list
mailing list