diff --git a/fiasko_bro/repository_info.py b/fiasko_bro/repository_info.py index 926b46e..3a40223 100644 --- a/fiasko_bro/repository_info.py +++ b/fiasko_bro/repository_info.py @@ -67,6 +67,8 @@ def is_tracked_directory(self, directory): class ProjectFolder: def __init__(self, path, directories_to_skip=None): + if not os.path.isdir(path): + raise FileNotFoundError('Path "{}" not found or is not a directory.'.format(path)) self.path = path self._parsed_py_files = self._get_parsed_py_files(directories_to_skip) try: diff --git a/tests/test_validation_interface/test_incorrect_input_handled.py b/tests/test_validation_interface/test_incorrect_input_handled.py new file mode 100644 index 0000000..ee91a3a --- /dev/null +++ b/tests/test_validation_interface/test_incorrect_input_handled.py @@ -0,0 +1,17 @@ +import os.path + +import pytest + +from fiasko_bro import validate + + +@pytest.fixture(scope='session') +def non_existent_directory(): + directory = 'test_fixtures{}directory_that_should_not_exist'.format(os.path.sep) + assert not os.path.isdir(directory) + return directory + + +def test_not_existing_file_raises_correct_exception(non_existent_directory): + with pytest.raises(FileNotFoundError): + validate(non_existent_directory)