<div dir="ltr">Why not just use pytest?<br><br>On Wednesday, October 10, 2018 at 7:12:02 AM UTC-4, David Shawley wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style="word-wrap:break-word;line-break:after-white-space"><div><span style="font-family:Menlo">Hi everyone and good morning to some of you,</span></div><div><span style="font-family:Menlo"><br></span></div><div><span style="font-family:Menlo">Since asyncio and the async/await syntax are both part of Python, I think</span></div><div><span style="font-family:Menlo">that we should extend TestCase to support it.  The simplest solution that</span></div><div><span style="font-family:Menlo">I can think of is to </span><span style="font-family:Menlo">create unittest.AsyncTestCase sub-class with the</span></div><div><span style="font-family:Menlo">following extensions:</span></div><div><span style="font-family:Menlo"><br></span></div><div><span style="font-family:Menlo"> - create a new event </span><font face="Menlo">loop</font><span style="font-family:Menlo"> and install it in AsyncTestCase.run</span></div><div><span style="font-family:Menlo"> - make it possible for setUp, tearDown, and test methods to be async</span></div><div><span style="font-family:Menlo">   by calling asyncio.iscoroutinefunction</span></div><div><span style="font-family:Menlo"><br></span></div><div><span style="font-family:Menlo">I wrote my own in a local test before noticing that Martin Richard had</span></div><div><span style="font-family:Menlo">already written and published asynctest [1].  Since then I found the</span></div><div><span style="font-family:Menlo">following projects as well:</span></div><div><span style="font-family:Menlo"><br></span></div><div><span style="font-family:Menlo"> - </span><font face="Menlo"><a href="https://github.com/kwarunek/aiounittest" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fkwarunek%2Faiounittest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjvyiZj3SzjdJuGd6168qHCbSrAw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fkwarunek%2Faiounittest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjvyiZj3SzjdJuGd6168qHCbSrAw';return true;">https://github.com/<wbr>kwarunek/aiounittest</a></font></div><div><font face="Menlo"> - <a href="https://github.com/pytest-dev/pytest-asyncio" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpytest-dev%2Fpytest-asyncio\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGY5TMqE0u62TQpGrLuOKYDITbJoA';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpytest-dev%2Fpytest-asyncio\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGY5TMqE0u62TQpGrLuOKYDITbJoA';return true;">https://github.com/pytest-<wbr>dev/pytest-asyncio</a></font></div><div><br></div><div><font face="Menlo">I think that the community as a whole would benefit from basic support in</font></div><div><font face="Menlo">unittest for async/await test "user methods".  I am personally fond of the</font></div><div><font face="Menlo">approach of extending unittest.TestCase in asynctest [2] </font><span style="font-family:Menlo">over some of the</span></div><div><span style="font-family:Menlo">other approaches.</span></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">Is this something that we want in our Standard Library?</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">- dave</font></div><div><font face="Menlo">--</font></div><div><span style="font-family:Menlo">[1]: </span><font face="Menlo"><a href="https://github.com/Martiusweb/asynctest" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMartiusweb%2Fasynctest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGtn17vU6E9LOq5OJVi-My_oij4rg';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMartiusweb%2Fasynctest\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGtn17vU6E9LOq5OJVi-My_oij4rg';return true;">https://github.com/<wbr>Martiusweb/asynctest</a></font></div><div><font face="Menlo">[2]: </font><a href="https://github.com/Martiusweb/asynctest/blob/master/asynctest/case.py" style="font-family:Menlo" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMartiusweb%2Fasynctest%2Fblob%2Fmaster%2Fasynctest%2Fcase.py\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCOsUSc73muG1R9_N-EY7-7KYYnA';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMartiusweb%2Fasynctest%2Fblob%2Fmaster%2Fasynctest%2Fcase.py\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFCOsUSc73muG1R9_N-EY7-7KYYnA';return true;">https://github.com/<wbr>Martiusweb/asynctest/blob/<wbr>master/asynctest/case.py</a></div></div></blockquote></div>