@@ -33,8 +33,6 @@ async def hidden_query(
3333return {"hidden_query" :hidden_query }
3434
3535
36- client = TestClient (app )
37-
3836openapi_shema = {
3937"openapi" :"3.0.2" ,
4038"info" : {"title" :"FastAPI" ,"version" :"0.1.0" },
@@ -161,6 +159,7 @@ async def hidden_query(
161159
162160
163161def test_openapi_schema ():
162+ client = TestClient (app )
164163response = client .get ("/openapi.json" )
165164assert response .status_code == 200
166165assert response .json ()== openapi_shema
@@ -184,7 +183,8 @@ def test_openapi_schema():
184183 ],
185184)
186185def test_hidden_cookie (path ,cookies ,expected_status ,expected_response ):
187- response = client .get (path ,cookies = cookies )
186+ client = TestClient (app ,cookies = cookies )
187+ response = client .get (path )
188188assert response .status_code == expected_status
189189assert response .json ()== expected_response
190190
@@ -207,12 +207,14 @@ def test_hidden_cookie(path, cookies, expected_status, expected_response):
207207 ],
208208)
209209def test_hidden_header (path ,headers ,expected_status ,expected_response ):
210+ client = TestClient (app )
210211response = client .get (path ,headers = headers )
211212assert response .status_code == expected_status
212213assert response .json ()== expected_response
213214
214215
215216def test_hidden_path ():
217+ client = TestClient (app )
216218response = client .get ("/hidden_path/hidden_path" )
217219assert response .status_code == 200
218220assert response .json ()== {"hidden_path" :"hidden_path" }
@@ -234,6 +236,7 @@ def test_hidden_path():
234236 ],
235237)
236238def test_hidden_query (path ,expected_status ,expected_response ):
239+ client = TestClient (app )
237240response = client .get (path )
238241assert response .status_code == expected_status
239242assert response .json ()== expected_response