Test the run_background_task utility function.
()
| 88 | |
| 89 | @pytest.mark.asyncio |
| 90 | async def test_run_background_task(): |
| 91 | """Test the run_background_task utility function.""" |
| 92 | result = {} |
| 93 | |
| 94 | async def co(): |
| 95 | result["start"] = 1 |
| 96 | await asyncio.sleep(0) |
| 97 | result["end"] = 1 |
| 98 | |
| 99 | run_background_task(co()) |
| 100 | |
| 101 | # Background task is running. |
| 102 | assert len(_BACKGROUND_TASKS) == 1 |
| 103 | # co executed. |
| 104 | await asyncio.sleep(0) |
| 105 | # await asyncio.sleep(0) from co is reached. |
| 106 | await asyncio.sleep(0) |
| 107 | # co finished and callback called. |
| 108 | await asyncio.sleep(0) |
| 109 | # The task should be removed from the set once it finishes. |
| 110 | assert len(_BACKGROUND_TASKS) == 0 |
| 111 | |
| 112 | assert result.get("start") == 1 |
| 113 | assert result.get("end") == 1 |
| 114 | |
| 115 | |
| 116 | class TestTryToCreateDirectory: |
nothing calls this directly
no test coverage detected
searching dependent graphs…