import pytest from langchain_community.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__}'"