| Conditions | 3 |
| Total Lines | 17 |
| Code Lines | 14 |
| Lines | 17 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | from contextvars import ContextVar |
||
| 8 | def test_run_curio(kernel): |
||
| 9 | counter = ContextVar("counter", default=5) |
||
| 10 | |||
| 11 | async def reset_counter(): |
||
| 12 | if counter.get() == 5: |
||
| 13 | counter.set(0) |
||
| 14 | return 0 |
||
| 15 | return -1 |
||
| 16 | |||
| 17 | with Kernel() as k: |
||
| 18 | assert run(k, reset_counter) == 0 |
||
| 19 | assert run(k, reset_counter) == 0 |
||
| 20 | assert counter.get() == 5 |
||
| 21 | |||
| 22 | assert kernel.run(reset_counter) == 0 |
||
| 23 | assert kernel.run(reset_counter) == -1 |
||
| 24 | assert counter.get() == 0 |
||
| 25 |