Test that alazy_load propagates an exception if one of the scraping tasks fails.
(monkeypatch)
| 349 | |
| 350 | @pytest.mark.asyncio |
| 351 | async def test_alazy_load_partial_failure(monkeypatch): |
| 352 | """Test that alazy_load propagates an exception if one of the scraping tasks fails.""" |
| 353 | urls = ["http://example.com", "http://fail.com"] |
| 354 | loader = ChromiumLoader(urls, backend="playwright") |
| 355 | |
| 356 | async def partial_scraper(url): |
| 357 | if "fail" in url: |
| 358 | raise Exception("Scraping failed for " + url) |
| 359 | return f"<html>Content for {url}</html>" |
| 360 | |
| 361 | monkeypatch.setattr(loader, "ascrape_playwright", partial_scraper) |
| 362 | |
| 363 | with pytest.raises(Exception, match="Scraping failed for http://fail.com"): |
| 364 | [doc async for doc in loader.alazy_load()] |
| 365 | |
| 366 | |
| 367 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected