MCPcopy Index your code
hub / github.com/python/cpython / addAsyncCleanup

Method addAsyncCleanup

Lib/unittest/async_case.py:50–63  ·  view source on GitHub ↗
(self, func, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

48 pass
49
50 def addAsyncCleanup(self, func, /, *args, **kwargs):
51 # A trivial trampoline to addCleanup()
52 # the function exists because it has a different semantics
53 # and signature:
54 # addCleanup() accepts regular functions
55 # but addAsyncCleanup() accepts coroutines
56 #
57 # We intentionally don't add inspect.iscoroutinefunction() check
58 # for func argument because there is no way
59 # to check for async function reliably:
60 # 1. It can be "async def func()" itself
61 # 2. Class can implement "async def __call__()" method
62 # 3. Regular "def func()" that returns awaitable object
63 self.addCleanup(*(func, *args), **kwargs)
64
65 async def enterAsyncContext(self, cm):
66 """Enters the supplied asynchronous context manager.

Callers 4

enterAsyncContextMethod · 0.95
setUpMethod · 0.80
asyncSetUpMethod · 0.80
test_funcMethod · 0.80

Calls 1

addCleanupMethod · 0.80

Tested by 3

setUpMethod · 0.64
asyncSetUpMethod · 0.64
test_funcMethod · 0.64