core[patch]: Add unit test for str and repr for Document (#23414)

This commit is contained in:
Eugene Yurtsev 2024-06-25 14:28:21 -04:00 committed by GitHub
parent f055f2a1e3
commit 7e9e69c758
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,20 @@
from langchain_core.documents import Document
def test_str() -> None:
assert str(Document(page_content="Hello, World!")) == "page_content='Hello, World!'"
assert (
str(Document(page_content="Hello, World!", metadata={"a": 3}))
== "page_content='Hello, World!' metadata={'a': 3}"
)
def test_repr() -> None:
assert (
repr(Document(page_content="Hello, World!"))
== "Document(page_content='Hello, World!')"
)
assert (
repr(Document(page_content="Hello, World!", metadata={"a": 3}))
== "Document(page_content='Hello, World!', metadata={'a': 3})"
)