from typing import List
from typing import Optional
from typing import Match
import re


def _get_passing_test_num_from_stdout(stdout: str) -> str:
    """
    Get a passing tests number from the stdout.

    Parameters
    ----------
    stdout : str
        Test command stdout.

    Returns
    -------
    passing_test_num : str
        Retrieved passing tests number.
    """
    lines: List[str] = stdout.splitlines()
    passing_test_num: str = ''
    for line in lines:
        if ' passed in ' not in line:
            continue
        match: Optional[Match] = re.search(
            pattern=r'.*? (\d+?) passed',
            string=line)
        if match is None:
            continue
        passing_test_num = match.group(1)
    return passing_test_num