Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7068 from RonnyPfannschmidt/backport-6927-run-asy…
…nc-unittest backport #6927: run async testcase methods
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
# dummy pytest.ini to ease direct running of example scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from unittest import IsolatedAsyncioTestCase # type: ignore | ||
|
||
|
||
class AsyncArguments(IsolatedAsyncioTestCase): | ||
async def test_something_async(self): | ||
async def addition(x, y): | ||
return x + y | ||
|
||
self.assertEqual(await addition(2, 2), 4) | ||
|
||
async def test_something_async_fails(self): | ||
async def addition(x, y): | ||
return x + y | ||
|
||
self.assertEqual(await addition(2, 2), 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters