@@ -100,13 +100,14 @@ async def test_allows_when_robots_txt_404(self):
100100 with patch ("httpx.AsyncClient" ) as mock_client_class :
101101 mock_client = AsyncMock ()
102102 mock_client .get = AsyncMock (return_value = mock_response )
103- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
103+ mock_client_class .return_value .__aenter__ = AsyncMock (
104+ return_value = mock_client
105+ )
104106 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
105107
106108 # Should not raise
107109 await check_may_autonomously_fetch_url (
108- "https://example.com/page" ,
109- DEFAULT_USER_AGENT_AUTONOMOUS
110+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
110111 )
111112
112113 @pytest .mark .asyncio
@@ -118,13 +119,14 @@ async def test_blocks_when_robots_txt_401(self):
118119 with patch ("httpx.AsyncClient" ) as mock_client_class :
119120 mock_client = AsyncMock ()
120121 mock_client .get = AsyncMock (return_value = mock_response )
121- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
122+ mock_client_class .return_value .__aenter__ = AsyncMock (
123+ return_value = mock_client
124+ )
122125 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
123126
124127 with pytest .raises (McpError ):
125128 await check_may_autonomously_fetch_url (
126- "https://example.com/page" ,
127- DEFAULT_USER_AGENT_AUTONOMOUS
129+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
128130 )
129131
130132 @pytest .mark .asyncio
@@ -136,13 +138,14 @@ async def test_blocks_when_robots_txt_403(self):
136138 with patch ("httpx.AsyncClient" ) as mock_client_class :
137139 mock_client = AsyncMock ()
138140 mock_client .get = AsyncMock (return_value = mock_response )
139- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
141+ mock_client_class .return_value .__aenter__ = AsyncMock (
142+ return_value = mock_client
143+ )
140144 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
141145
142146 with pytest .raises (McpError ):
143147 await check_may_autonomously_fetch_url (
144- "https://example.com/page" ,
145- DEFAULT_USER_AGENT_AUTONOMOUS
148+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
146149 )
147150
148151 @pytest .mark .asyncio
@@ -155,13 +158,14 @@ async def test_allows_when_robots_txt_allows_all(self):
155158 with patch ("httpx.AsyncClient" ) as mock_client_class :
156159 mock_client = AsyncMock ()
157160 mock_client .get = AsyncMock (return_value = mock_response )
158- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
161+ mock_client_class .return_value .__aenter__ = AsyncMock (
162+ return_value = mock_client
163+ )
159164 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
160165
161166 # Should not raise
162167 await check_may_autonomously_fetch_url (
163- "https://example.com/page" ,
164- DEFAULT_USER_AGENT_AUTONOMOUS
168+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
165169 )
166170
167171 @pytest .mark .asyncio
@@ -174,13 +178,14 @@ async def test_blocks_when_robots_txt_disallows_all(self):
174178 with patch ("httpx.AsyncClient" ) as mock_client_class :
175179 mock_client = AsyncMock ()
176180 mock_client .get = AsyncMock (return_value = mock_response )
177- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
181+ mock_client_class .return_value .__aenter__ = AsyncMock (
182+ return_value = mock_client
183+ )
178184 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
179185
180186 with pytest .raises (McpError ):
181187 await check_may_autonomously_fetch_url (
182- "https://example.com/page" ,
183- DEFAULT_USER_AGENT_AUTONOMOUS
188+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
184189 )
185190
186191
@@ -207,12 +212,13 @@ async def test_fetch_html_page(self):
207212 with patch ("httpx.AsyncClient" ) as mock_client_class :
208213 mock_client = AsyncMock ()
209214 mock_client .get = AsyncMock (return_value = mock_response )
210- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
215+ mock_client_class .return_value .__aenter__ = AsyncMock (
216+ return_value = mock_client
217+ )
211218 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
212219
213220 content , prefix = await fetch_url (
214- "https://example.com/page" ,
215- DEFAULT_USER_AGENT_AUTONOMOUS
221+ "https://example.com/page" , DEFAULT_USER_AGENT_AUTONOMOUS
216222 )
217223
218224 # HTML is processed, so we check it returns something
@@ -231,13 +237,15 @@ async def test_fetch_html_page_raw(self):
231237 with patch ("httpx.AsyncClient" ) as mock_client_class :
232238 mock_client = AsyncMock ()
233239 mock_client .get = AsyncMock (return_value = mock_response )
234- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
240+ mock_client_class .return_value .__aenter__ = AsyncMock (
241+ return_value = mock_client
242+ )
235243 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
236244
237245 content , prefix = await fetch_url (
238246 "https://example.com/page" ,
239247 DEFAULT_USER_AGENT_AUTONOMOUS ,
240- force_raw = True
248+ force_raw = True ,
241249 )
242250
243251 assert content == html_content
@@ -255,12 +263,13 @@ async def test_fetch_json_returns_raw(self):
255263 with patch ("httpx.AsyncClient" ) as mock_client_class :
256264 mock_client = AsyncMock ()
257265 mock_client .get = AsyncMock (return_value = mock_response )
258- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
266+ mock_client_class .return_value .__aenter__ = AsyncMock (
267+ return_value = mock_client
268+ )
259269 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
260270
261271 content , prefix = await fetch_url (
262- "https://api.example.com/data" ,
263- DEFAULT_USER_AGENT_AUTONOMOUS
272+ "https://api.example.com/data" , DEFAULT_USER_AGENT_AUTONOMOUS
264273 )
265274
266275 assert content == json_content
@@ -275,13 +284,14 @@ async def test_fetch_404_raises_error(self):
275284 with patch ("httpx.AsyncClient" ) as mock_client_class :
276285 mock_client = AsyncMock ()
277286 mock_client .get = AsyncMock (return_value = mock_response )
278- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
287+ mock_client_class .return_value .__aenter__ = AsyncMock (
288+ return_value = mock_client
289+ )
279290 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
280291
281292 with pytest .raises (McpError ):
282293 await fetch_url (
283- "https://example.com/notfound" ,
284- DEFAULT_USER_AGENT_AUTONOMOUS
294+ "https://example.com/notfound" , DEFAULT_USER_AGENT_AUTONOMOUS
285295 )
286296
287297 @pytest .mark .asyncio
@@ -293,13 +303,14 @@ async def test_fetch_500_raises_error(self):
293303 with patch ("httpx.AsyncClient" ) as mock_client_class :
294304 mock_client = AsyncMock ()
295305 mock_client .get = AsyncMock (return_value = mock_response )
296- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
306+ mock_client_class .return_value .__aenter__ = AsyncMock (
307+ return_value = mock_client
308+ )
297309 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
298310
299311 with pytest .raises (McpError ):
300312 await fetch_url (
301- "https://example.com/error" ,
302- DEFAULT_USER_AGENT_AUTONOMOUS
313+ "https://example.com/error" , DEFAULT_USER_AGENT_AUTONOMOUS
303314 )
304315
305316 @pytest .mark .asyncio
@@ -313,14 +324,18 @@ async def test_fetch_with_proxy(self):
313324 with patch ("httpx.AsyncClient" ) as mock_client_class :
314325 mock_client = AsyncMock ()
315326 mock_client .get = AsyncMock (return_value = mock_response )
316- mock_client_class .return_value .__aenter__ = AsyncMock (return_value = mock_client )
327+ mock_client_class .return_value .__aenter__ = AsyncMock (
328+ return_value = mock_client
329+ )
317330 mock_client_class .return_value .__aexit__ = AsyncMock (return_value = None )
318331
319332 await fetch_url (
320333 "https://example.com/data" ,
321334 DEFAULT_USER_AGENT_AUTONOMOUS ,
322- proxy_url = "http://proxy.example.com:8080"
335+ proxy_url = "http://proxy.example.com:8080" ,
323336 )
324337
325338 # Verify AsyncClient was called with proxy
326- mock_client_class .assert_called_once_with (proxy = "http://proxy.example.com:8080" )
339+ mock_client_class .assert_called_once_with (
340+ proxy = "http://proxy.example.com:8080"
341+ )
0 commit comments