Test that lazy_load yields a Document with empty content if the scraper returns an empty string.
(monkeypatch)
| 1083 | |
| 1084 | |
| 1085 | def test_lazy_load_empty_content(monkeypatch): |
| 1086 | """Test that lazy_load yields a Document with empty content if the scraper returns an empty string.""" |
| 1087 | from langchain_core.documents import Document |
| 1088 | |
| 1089 | urls = ["http://example.com"] |
| 1090 | loader = ChromiumLoader(urls, backend="playwright", requires_js_support=False) |
| 1091 | |
| 1092 | async def dummy_scraper(url): |
| 1093 | return "" |
| 1094 | |
| 1095 | monkeypatch.setattr(loader, "ascrape_playwright", dummy_scraper) |
| 1096 | docs = list(loader.lazy_load()) |
| 1097 | assert len(docs) == 1 |
| 1098 | for doc in docs: |
| 1099 | assert isinstance(doc, Document) |
| 1100 | assert doc.page_content == "" |
| 1101 | assert doc.metadata["source"] in urls |
| 1102 | |
| 1103 | |
| 1104 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected