From 7e9e69c7586d67f381ec7d8554bfccb92d6d0843 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Tue, 25 Jun 2024 14:28:21 -0400 Subject: [PATCH] core[patch]: Add unit test for str and repr for Document (#23414) --- .../tests/unit_tests/documents/test_str.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libs/core/tests/unit_tests/documents/test_str.py diff --git a/libs/core/tests/unit_tests/documents/test_str.py b/libs/core/tests/unit_tests/documents/test_str.py new file mode 100644 index 0000000000..fd44d06a98 --- /dev/null +++ b/libs/core/tests/unit_tests/documents/test_str.py @@ -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})" + )