o
    v&i	                     @  sV   d Z ddlmZ ddlmZ ddlmZ ddlmZ dd
dZ	dddZ
dddZdS )z"Determine contexts for coverage.py    )annotations)Sequence)	FrameType)TShouldStartContextFncontext_switchersSequence[TShouldStartContextFn]returnTShouldStartContextFn | Nonec                   s.    sdS t  dkr d S d
 fdd	}|S )a  Create a single context switcher from multiple switchers.

    `context_switchers` is a list of functions that take a frame as an
    argument and return a string to use as the new context label.

    Returns a function that composites `context_switchers` functions, or None
    if `context_switchers` is an empty list.

    When invoked, the combined switcher calls `context_switchers` one-by-one
    until a string is returned.  The combined switcher returns None if all
    `context_switchers` return None.
    N   r   framer   r   
str | Nonec                   s&    D ]}|| }|dur|  S qdS )z,The combiner for multiple context switchers.N )r   switchernew_contextr   r   V/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/coverage/context.pyshould_start_context#   s   z7combine_context_switchers.<locals>.should_start_contextr   r   r   r   )len)r   r   r   r   r   combine_context_switchers   s   r   r   r   r   c                 C  s&   | j j}|ds|dkrt| S dS )z(Is this frame calling a test_* function?testrunTestN)f_codeco_name
startswithqualname_from_frame)r   r   r   r   r   "should_start_context_test_function.   s   r   c                 C  s   | j }|j}d}|jr|jd dkr| jdd}t||d}|du r7| j|}|du r/dS |j d| S t|dd}|du rP|j	}|j d|j
 d| S |j d|j S )z5Get a qualified name for the code running in `frame`.Nr   self.__func__)r   r   co_argcountco_varnamesf_localsgetgetattr	f_globals
__module__	__class____name____qualname__)r   cofnamemethodr   funcclsr   r   r   r   6   s    r   N)r   r   r   r	   r   )__doc__
__future__r   collections.abcr   typesr   coverage.typesr   r   r   r   r   r   r   r   <module>   s   

 