generated from jCloud/repository-template
28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
from src.jcloud_docsgen._utils import ExistingDirectory
|
|
import pytest
|
|
import pathlib
|
|
|
|
@pytest.mark.parametrize('path,expected', [
|
|
('tests/unit/_utils/test_directory/', 'tests/unit/_utils/test_directory'),
|
|
('tests/unit/_utils/test_directory', 'tests/unit/_utils/test_directory'),
|
|
('tests/unit/_utils/', 'tests/unit/_utils'),
|
|
('tests/unit/_utils', 'tests/unit/_utils'),
|
|
('/', '/'),
|
|
('./', '.'),
|
|
('.', '.'),
|
|
('../', '..'),
|
|
('..', '..'),
|
|
])
|
|
def test_ExistingDirectory(path, expected):
|
|
assert ExistingDirectory(path).as_posix() == expected
|
|
|
|
@pytest.mark.parametrize('path,expected_exception,expected_exception_message', [
|
|
('tests/unit/_utils/does_not_exist/', FileNotFoundError, '[Errno 2] no such file or directory: \'tests/unit/_utils/does_not_exist/\''),
|
|
('tests/unit/_utils/does_not_exist', FileNotFoundError, '[Errno 2] no such file or directory: \'tests/unit/_utils/does_not_exist\''),
|
|
('', FileNotFoundError, '[Errno 2] no such file or directory: \'\''),
|
|
('README.md', NotADirectoryError, '[Errno 20] not a directory: \'README.md\''),
|
|
])
|
|
def test_ExistingDirectory_exceptions(path, expected_exception, expected_exception_message):
|
|
with pytest.raises(expected_exception) as exc_info:
|
|
ExistingDirectory(path)
|
|
assert str(exc_info.value) == expected_exception_message |