import re


def parse_session(lines):
    """
    Parse the pytest `session` section to extract the `root dir` of the test
    session.

    :param lines: All reported output lines from the `test session start`
        section.

    :returns: The test session root path.
    """
    session = re.compile(r"={2,} test session starts ={2,}")

    if not session.match(lines[0]):
        return None

    m = re.match(r"rootdir: (?P<root>.*), inifile: (?P<ini>.*)$", lines[2])
    if not m:
        return None
    return m.group('root')