From 048d7ad3bb9439c665607d40da1ad63803bda9a6 Mon Sep 17 00:00:00 2001 From: Chaitanya Sai Meka Date: Mon, 10 Nov 2025 16:21:20 +0530 Subject: [PATCH] test: finalize client fixture and absolute import for needs_pydanticv2 --- .../test_tutorial006d_an_py310.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_tutorial/test_query_params_str_validations/test_tutorial006d_an_py310.py b/tests/test_tutorial/test_query_params_str_validations/test_tutorial006d_an_py310.py index af7e9dd09..113ab2f93 100644 --- a/tests/test_tutorial/test_query_params_str_validations/test_tutorial006d_an_py310.py +++ b/tests/test_tutorial/test_query_params_str_validations/test_tutorial006d_an_py310.py @@ -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}