def exec_tests(
    tests: Iterable[Doctest], quiet: bool = True
) -> tuple[doctest.TestResults, list[str]]:
    """Runs a list of `Doctest`s and collects and returns any error messages.

    Args:
        tests: The tests to run
        quiet: If True, suppress console output.

    Returns: A tuple containing the results (# failures, # attempts) and a list
        of the error outputs from each failing test.
    """
    if not quiet:
        try_print = print
    else:
        try_print = lambda *args, **kwargs: None
    try_print('Executing tests ', end='')

    failed, attempted = 0, 0
    error_messages = []
    for test in tests:
        out = OutputCapture()
        with out:
            r = test.run()
        failed += r.failed
        attempted += r.attempted
        if r.failed != 0:
            try_print('F', end='', flush=True)
            error = shell_tools.highlight(
                f'{test.file_name}\n'
                f'{r.failed} failed, {r.attempted - r.failed} passed, {r.attempted} total\n',
                shell_tools.RED,
            )
            error += out.content()
            error_messages.append(error)
        else:
            try_print('.', end='', flush=True)

    try_print()

    return doctest.TestResults(failed=failed, attempted=attempted), error_messages
Runs a list of `Doctest`s and collects and returns any error messages.

    Args:
        tests: The tests to run
        quiet: If True, suppress console output.

    Returns: A tuple containing the results (# failures, # attempts) and a list
        of the error outputs from each failing test.
    
dev_tools/docs/run_doctest.py