def test__get_list_of_files_in__path_is_not_dir(path_mock): glob = '*.not_here' path_mock.exists.return_value = True path_mock.is_dir.return_value = False with pytest.raises(AssertionError) as excinfo: get_list_of_files_in(path_mock, glob) assert 'path is not a directory' in str(excinfo.value)
def test__get_list_of_files_in__returns_list(path_mock): glob = '*.not_here' generator = [i for i in range(1,100)] path_mock.exists.return_value = True path_mock.is_dir.return_value = True path_mock.glob.return_value = generator assert get_list_of_files_in(path_mock, glob) == list(generator) assert path_mock.mock_calls == [call.exists(), call.is_dir(), call.glob(glob)]
def test__get_list_of_files_in__dir_not_exists(path_mock): glob = '*.not_here' path_mock.exists.return_value = False with pytest.raises(AssertionError) as excinfo: get_list_of_files_in(path_mock, glob) assert 'path does not exist' in str(excinfo.value)