Skip to content

Commit 407d444

Browse files
Add test for async context manager.
1 parent 6035572 commit 407d444

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/core/test_object_proxy.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,29 @@ def __exit__(*args, **kwargs):
838838
with wrapper:
839839
pass
840840

841+
def test_async_context_manager(self):
842+
class Class:
843+
async def __aenter__(self):
844+
return self
845+
846+
async def __aexit__(*args, **kwargs):
847+
return
848+
849+
instance = Class()
850+
851+
wrapper = wrapt.ObjectProxy(instance)
852+
853+
async def run():
854+
async with wrapper:
855+
pass
856+
857+
import asyncio
858+
859+
loop = asyncio.new_event_loop()
860+
asyncio.set_event_loop(loop)
861+
loop.run_until_complete(run())
862+
loop.close()
863+
841864

842865
class TestEqualityObjectProxy(unittest.TestCase):
843866

0 commit comments

Comments
 (0)