예제 #1
0
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)
예제 #2
0
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)]
예제 #3
0
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)