MCPcopy Create free account
hub / github.com/django-commons/django-debug-toolbar / AsyncToolbarTestClient

Class AsyncToolbarTestClient

tests/base.py:42–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41
42class AsyncToolbarTestClient(AsyncClient):
43 async def request(self, **request):
44 # Use a thread/async task context-local variable to guard against a
45 # concurrent _created signal from a different thread/task.
46 # In cases testsuite will have both regular and async tests or
47 # multiple async tests running in an eventloop making async_client calls.
48 data_contextvar.set(None)
49
50 def handle_toolbar_created(sender, toolbar=None, **kwargs):
51 data_contextvar.set(toolbar)
52
53 DebugToolbar._created.connect(handle_toolbar_created)
54 try:
55 response = await super().request(**request)
56 finally:
57 DebugToolbar._created.disconnect(handle_toolbar_created)
58 response.toolbar = data_contextvar.get()
59
60 return response
61
62
63rf = RequestFactory()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…