test: finalize client fixture and absolute import for needs_pydanticv2

This commit is contained in:
Chaitanya Sai Meka 2025-11-10 16:21:20 +05:30
parent 6d334327d8
commit 048d7ad3bb
1 changed files with 7 additions and 4 deletions

View File

@ -1,11 +1,14 @@
import pytest
from fastapi.testclient import TestClient
from tests.utils import needs_pydanticv2
from docs_src.query_params_str_validations.tutorial006d_an_py310 import app
client = TestClient(app)
@pytest.fixture
def client():
from docs_src.query_params_str_validations.tutorial006d_an_py310 import app
yield TestClient(app)
@needs_pydanticv2
@pytest.mark.parametrize(
"q_value,expected",
[
@ -15,7 +18,7 @@ client = TestClient(app)
("hello", "hello"),
],
)
def test_read_items(q_value, expected):
def test_read_items(q_value, expected, client: TestClient):
response = client.get("/items/", params={"q": q_value})
assert response.status_code == 200
assert response.json() == {"q": expected}