def filter_passing_tests(
    test_content: str, test_output: str, repo: str
) -> tuple[str, list[str], list[str]]:
    """
    Filter tests based on their execution results.
    Returns:
        Tuple containing:
        - Modified test content with only passing tests
        - List of passing test names
        - List of failing test names
    """
    # Parse test results using appropriate parser
    parser = MAP_REPO_TO_PARSER.get(repo, parse_log_pytest)
    test_results = parser(test_output)
    # Get passing and failing tests
    passing_tests = []
    failing_tests = []
    for test_name, status in test_results.items():
        if status == TestStatus.PASSED.value:
            passing_tests.append(test_name)
        else:
            failing_tests.append(test_name)

    if not passing_tests:
        return '', passing_tests, failing_tests

    # Extract test components
    preamble, classes, functions = extract_preamble_classes_and_functions(test_content)

    # Filter classes to only include passing methods
    filtered_classes = []
    for class_name, methods, start_idx in classes:
        non_fail_methods = []
        for method_name, method_body in methods:
            # Extract the base method name for matching
            method_full_name = (
                method_name.split('.')[-1].split('(')[0].strip().split(' ')[-1]
            )
            # Check if the method name is in failing_tests or if any failing_test is in the method name
            if not (
                any(method_full_name in failing_test for failing_test in failing_tests)
                or any(
                    failing_test in method_full_name for failing_test in failing_tests
                )
            ):
                non_fail_methods.append((method_name, method_body))

        if non_fail_methods:
            filtered_classes.append((class_name, non_fail_methods, start_idx))

    # Filter standalone functions
    filtered_functions = []
    for func_body, start_idx in functions:
        func_name = func_body.split('def ')[1].split('(')[0].strip()
        if any(func_name in failing_test for failing_test in failing_tests) or any(
            failing_test in func_name for failing_test in failing_tests
        ):
            continue

        filtered_functions.append((func_body, start_idx))

    # Reconstruct test content with only passing tests
    content_parts = [preamble]

    # Add filtered classes
    for class_name, methods, _ in filtered_classes:
        class_content = class_name + '\n'
        for _, method_body in methods:
            class_content += method_body + '\n'
        content_parts.append(class_content)

    # Add filtered functions
    for func_body, _ in filtered_functions:
        content_parts.append(func_body)

    return '\n\n'.join(content_parts), passing_tests, failing_tests

    Filter tests based on their execution results.
    Returns:
        Tuple containing:
        - Modified test content with only passing tests
        - List of passing test names
        - List of failing test names
    
evaluation/benchmarks/testgeneval/test_filter.py