def pytest_parser(stdout, stderr, previous_reports=None):
    """
    Example fail summary_line: =========== 4 failed, 38 passed in 0.10 seconds =============
    Example success summary_line: ========= 21 passed in 0.05 seconds =========
    """
    lines = stdout.split('\n')
    summary_line = lines[-2].split()

    if summary_line[2].lower() == 'passed':
        passed_tests = int(summary_line[1])
        failed_tests = 0
    else:
        passed_tests = int(summary_line[3])
        failed_tests = int(summary_line[1])

    return {
        'stdout': stdout,
        'stderr': stderr,
        'summary': {
            'passed_tests': passed_tests,
            'failed_tests': failed_tests,
            'total_tests': passed_tests + failed_tests
        }
    }