@@ -36,16 +36,14 @@ def mock_jwks(public_key: dict[str, Any]):
3636 mock_jwks = {"keys" : [public_key ]}
3737
3838 with (
39- patch ("urllib.request.urlopen " ) as mock_urlopen ,
39+ patch ("httpx.get " ) as mock_urlopen ,
4040 patch ("jwt.PyJWKClient.fetch_data" ) as mock_fetch_data ,
4141 ):
4242 mock_oidc_config_response = MagicMock ()
43- mock_oidc_config_response .read .return_value = json .dumps (
44- mock_oidc_config
45- ).encode ()
43+ mock_oidc_config_response .json .return_value = mock_oidc_config
4644 mock_oidc_config_response .status = 200
4745
48- mock_urlopen .return_value . __enter__ . return_value = mock_oidc_config_response
46+ mock_urlopen .return_value = mock_oidc_config_response
4947 mock_fetch_data .return_value = mock_jwks
5048 yield mock_urlopen
5149
@@ -121,7 +119,7 @@ def source_api():
121119 return app
122120
123121
124- @pytest .fixture
122+ @pytest .fixture ( scope = "session" )
125123def source_api_server (source_api ):
126124 """Run the source API in a background thread."""
127125 host , port = "127.0.0.1" , 9119
@@ -139,7 +137,7 @@ def source_api_server(source_api):
139137 thread .join ()
140138
141139
142- @pytest .fixture (autouse = True , scope = "module " )
140+ @pytest .fixture (autouse = True , scope = "session " )
143141def mock_env ():
144142 """Clear environment variables to avoid poluting configs from runtime env."""
145143 with patch .dict (os .environ , clear = True ):
0 commit comments