You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/tests/unit_tests/document_loaders/test_directory.py

20 lines
556 B
Python

import pytest
from langchain.document_loaders import DirectoryLoader
def test_raise_error_if_path_not_exist() -> None:
loader = DirectoryLoader("./not_exist_directory")
with pytest.raises(FileNotFoundError) as e:
loader.load()
assert str(e.value) == "Directory not found: './not_exist_directory'"
def test_raise_error_if_path_is_not_directory() -> None:
loader = DirectoryLoader(__file__)
with pytest.raises(ValueError) as e:
loader.load()
assert str(e.value) == f"Expected directory, got file: '{__file__}'"