Skip to content

Commit da979a9

Browse files
committed
refactor: configure anyio for testing tasks REFS #73
1 parent 649ebe0 commit da979a9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/tests/conftest.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
"""
1+
""" Configuration required for tests to run
2+
3+
Note that fastapi makes available a test client that can be used to
4+
test the API endpoints. This will call the endpoints internally.
25
6+
For the taskiq to work we have configured it to use the InMemoryBroker
7+
otherwise it will try to connect to a redis server.
8+
9+
Please note you will require pytest-env for the environment variables
10+
to work which are set via pyproject.toml
311
"""
412
import pytest
513

14+
615
@pytest.fixture(scope='session')
716
def test_client():
817
from fastapi.testclient import TestClient
918
from labs.api import app
1019
return TestClient(app)
20+
21+
22+
@pytest.fixture
23+
def anyio_backend():
24+
""" Since taskiq is fully async, we suggest using anyio
25+
26+
See configuration described in the docs:
27+
https://taskiq-python.github.io/guide/testing-taskiq.html#async-tests
28+
"""
29+
return 'asyncio'

0 commit comments

Comments
 (0)