| 40 | |
| 41 | |
| 42 | class 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 | |
| 63 | rf = RequestFactory() |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…