def test_build_tree_with_search_string( mock_current_directory_path: Path, mock_search_string: str, capsys ) -> None: Tree.build_tree(mock_current_directory_path, mock_search_string) captured = capsys.readouterr() assert len(captured.out) > 0
def test_fails_build_tree_for_a_nonexistent_path( mock_validate_inputs: Mock, mock_non_existent_path: Path, caplog ): with pytest.raises(SystemExit): logger.error("Directory/File not found.") Tree.build_tree(mock_non_existent_path) assert SystemExit() assert mock_validate_inputs.called assert "Directory/File not found." == caplog.messages[0]
def test_fails_build_tree_file_in_path_without_search_string( mock_validate_inputs: Mock, mock_path_with_file: Path, caplog ): with pytest.raises(SystemExit): logger.error("Provide a string to find references in the given file.") Tree.build_tree(mock_path_with_file) assert SystemExit() assert mock_validate_inputs.called assert ( "Provide a string to find references in the given file." == caplog.messages[0] )