Test that lazy_load propagates exception if the scraping function fails.
(loader_with_dummy, monkeypatch)
| 317 | |
| 318 | @pytest.mark.asyncio |
| 319 | async def test_lazy_load_exception(loader_with_dummy, monkeypatch): |
| 320 | """Test that lazy_load propagates exception if the scraping function fails.""" |
| 321 | |
| 322 | async def dummy_failure(url): |
| 323 | raise Exception("Dummy scraping error") |
| 324 | |
| 325 | # Patch the scraping method to always raise an exception |
| 326 | loader_with_dummy.backend = "playwright" |
| 327 | monkeypatch.setattr(loader_with_dummy, "ascrape_playwright", dummy_failure) |
| 328 | with pytest.raises(Exception, match="Dummy scraping error"): |
| 329 | list(loader_with_dummy.lazy_load()) |
| 330 | |
| 331 | |
| 332 | @pytest.mark.asyncio |