generated from jCloud/repository-template
22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
from src.jcloud_docsgen.utils import ExistingFile
|
|
import pytest
|
|
import pathlib
|
|
|
|
@pytest.mark.parametrize('path,expected', [
|
|
('tests/unit/utils/test_file', 'tests/unit/utils/test_file'),
|
|
('tests/unit/utils/test_symlink', 'tests/unit/utils/test_symlink'),
|
|
])
|
|
def test_ExistingDirectory(path, expected):
|
|
assert ExistingFile(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\''),
|
|
('', FileNotFoundError, '[Errno 2] no such file or directory: \'\''),
|
|
('tests/unit/utils/test_directory', IsADirectoryError, '[Errno 21] is a directory: \'tests/unit/utils/test_directory\''),
|
|
('.', IsADirectoryError, '[Errno 21] is a directory: \'.\''),
|
|
('./', IsADirectoryError, '[Errno 21] is a directory: \'./\''),
|
|
])
|
|
def test_ExistingDirectory_exceptions(path, expected_exception, expected_exception_message):
|
|
with pytest.raises(expected_exception) as exc_info:
|
|
ExistingFile(path)
|
|
assert str(exc_info.value) == expected_exception_message |