mirror of https://github.com/tiangolo/fastapi.git
test: finalize client fixture and absolute import for needs_pydanticv2
This commit is contained in:
parent
6d334327d8
commit
048d7ad3bb
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Reference in New Issue