The fetch function should handle 404 responses gracefully.
()
| 245 | |
| 246 | |
| 247 | async def test_fetch_404_error_handling(): |
| 248 | """ |
| 249 | The fetch function should handle 404 responses gracefully. |
| 250 | """ |
| 251 | response = await fetch("https://jsonplaceholder.typicode.com/todos/999999") |
| 252 | assert not response.ok |
| 253 | assert response.status == 404 |
| 254 | # Should still be able to extract data even from error responses. |
| 255 | data = await response.json() |
| 256 | assert data == {} |
| 257 | |
| 258 | |
| 259 | async def test_fetch_error_response_with_text(): |