mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
20 lines
556 B
Python
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__}'"
|