Files
mtusi2026lab2/tests_student/conftest.py
T

19 lines
482 B
Python

import os
import pytest
from httpx import ASGITransport, AsyncClient
from app.main import app
@pytest.fixture
async def client():
base_url = os.getenv("BASE_URL", "http://testserver")
if base_url.startswith("http://testserver"):
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://testserver") as ac:
yield ac
else:
async with AsyncClient(base_url=base_url) as ac:
yield ac