Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
heckad committed Jul 20, 2020
commit 858a98fbe9446e4ec781b7f3caaf90505ce2ca23
19 changes: 19 additions & 0 deletions Lib/test/test_contextlib_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,25 @@ async def woohoo(self, func, args, kwds):
async with woohoo(self=11, func=22, args=33, kwds=44) as target:
self.assertEqual(target, (11, 22, 33, 44))

async def test_recursive(self):
Comment thread
heckad marked this conversation as resolved.
depth = 0
Comment thread
heckad marked this conversation as resolved.
@asynccontextmanager
async def woohoo():
nonlocal depth
before = depth
depth += 1
Comment thread
heckad marked this conversation as resolved.
yield
depth -= 1
self.assertEqual(depth, before)

@woohoo()
async def recursive():
if depth < 10:
recursive()

await recursive()
self.assertEqual(depth, 0)
Comment thread
heckad marked this conversation as resolved.


class TestAsyncExitStack(TestBaseExitStack, unittest.TestCase):
class SyncAsyncExitStack(AsyncExitStack):
Expand Down