@@ -33,8 +33,6 @@ async def hidden_query(
3333 return {"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 )
164163 response = client .get ("/openapi.json" )
165164 assert response .status_code == 200
166165 assert 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 )
188188 assert response .status_code == expected_status
189189 assert 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 )
210
9423
td>211 response = client .get (path , headers = headers )
211212 assert response .status_code == expected_status
212213 assert response .json () == expected_response
213214
214215
215216def test_hidden_path ():
217+ client = TestClient (app )
216218 response = client .get ("/hidden_path/hidden_path" )
217219 assert response .status_code == 200
218220 assert 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 )
237240 response = client .get (path )
238241 assert response .status_code == expected_status
239242 assert response .json () == expected_response
0 commit comments