hc
2024-11-01 7e970c18f85f99acc678d90128b6e01dce1bf273
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
import pytest
 
 
x = 1
 
 
@pytest.fixture()
def f1():
    global x
    x = 2
    yield 15
    x = 3
 
 
@pytest.mark.asyncio
async def test_1():
    assert x == 1
 
 
@pytest.mark.asyncio
async def test_2(f1):
    assert x == 2
    assert f1 == 15
 
 
@pytest.mark.asyncio
async def test_3():
    assert x == 3
    await asyncio.sleep(0.1)
    assert x == 3