generated from jCloud/repository-template
Add class for existing files
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user