Completed
Push — master ( d5e257...2cfe0f )
by Guibert
12s queued 11s
created

tests.test_utils_run.test_run_curio()   A

Complexity

Conditions 3

Size

Total Lines 17
Code Lines 14

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 14
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
cc 3
nop 0
1
from contextvars import ContextVar
2
3
from curio import Kernel, run as _curio_run
4
5
from async_btree import run
6
7
8 View Code Duplication
def test_run_curio():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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 kernel:
18
        assert run(kernel, reset_counter) == 0
19
        assert run(kernel, reset_counter) == 0
20
        assert counter.get() == 5
21
22
    assert _curio_run(reset_counter) == 0
23
    assert _curio_run(reset_counter) == -1
24
    assert counter.get() == 0
25