support/testing: add pytest-asyncio test

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Marcin Niestroj
2020-12-22 17:39:16 +01:00
committed by Thomas Petazzoni
parent 2c4ad5ba24
commit 55a6ff34ba
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,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