o
    Zh%"                  
   @   sJ  d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ d	d
l	m
Z
 d	dl	mZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ erddlmZ g dZeee   Z dddde!deeeeeef  f dee" d efd!d"Z#d#ed dfd$d%Z$ed&d'd(ed eee%ef  fd)d*Z&ej'G d+d, d,Z(d-d.d(ed dfd/d0Z)ej'G d1d2 d2Z*d-d.d(ed dfd3d4Z+d5e"d6e"d e
fd7d8Z,d-d.d(ed dfd9d:Z-d(ed dfd;d<Z.d(ed dfd=d>Z/dS )?z=Generic mechanism for marking and selecting python functions.    N)AbstractSet)
Collection)List)Optional)TYPE_CHECKING)Union   )
Expression)
ParseError)EMPTY_PARAMETERSET_OPTION)get_empty_parameterset_mark)Mark)MARK_GEN)MarkDecorator)MarkGenerator)ParameterSet)Config)ExitCode)hookimpl)
UsageError)Parser)StashKey)Item)r   r   r   r   r   r    marksidvaluesr   r   returnc                 G   s   t j|| |dS )a  Specify a parameter in `pytest.mark.parametrize`_ calls or
    :ref:`parametrized fixtures <fixture-parametrize-marks>`.

    .. code-block:: python

        @pytest.mark.parametrize(
            "test_input,expected",
            [
                ("3+5", 8),
                pytest.param("6*9", 42, marks=pytest.mark.xfail),
            ],
        )
        def test_eval(test_input, expected):
            assert eval(test_input) == expected

    :param values: Variable args of the values of the parameter set, in order.
    :param marks: A single mark or a list of marks to be applied to this parameter set.
    :param id: The id to attribute to this parameter set.
    r   )r   param)r   r   r   r   r   L/var/www/html/lang_env/lib/python3.10/site-packages/_pytest/mark/__init__.pyr   -   s   r   parserc                 C   sd   |  d}|jddddddd |jd	dd
dddd |jdddd | ddd | td d S )NZgeneralz-kstorekeyword Z
EXPRESSIONa  Only run tests which match the given substring expression. An expression is a Python evaluatable expression where all names are substring-matched against test names and their parent classes. Example: -k 'test_method or test_other' matches all test functions and classes whose name contains 'test_method' or 'test_other', while -k 'not test_method' matches those that don't contain 'test_method' in their names. -k 'not test_method and not test_other' will eliminate the matches. Additionally keywords are matched to classes and functions containing extra names in their 'extra_keyword_matches' set, as well as functions which have names assigned directly to them. The matching is case-insensitive.)actiondestdefaultmetavarhelpz-mmarkexprZMARKEXPRzUOnly run tests matching given mark expression. For example: -m 'mark1 and not mark2'.z	--markers
store_truez4show markers (builtin, plugin and per-project ones).)r%   r)   markersz'Register new markers for test functionsZlinelistz&Default marker for empty parametersets)ZgetgroupZ
_addoptionZ	addoptionZaddinir   )r!   groupr   r   r    pytest_addoptionH   s0   

r.   T)Ztryfirstconfigc                 C   s   dd l }| jjrH|   |j| }| dD ]*}|dd}|d }t|dkr-|d nd}|j	d| dd	 |
| |
  q|   dS d S )
Nr   r,   :r      r$   z@pytest.mark.%s:T)bold)_pytest.configoptionr,   Z_do_configurer/   Zcreate_terminal_writergetinisplitlenwritelineZ_ensure_unconfigure)r/   Z_pytestZtwr9   partsnamerestr   r   r    pytest_cmdline_mainr   s   

r=   c                   @   B   e Zd ZU dZdZee ed< edddZ	d	ede
fd
dZdS )KeywordMatchera  A matcher for keywords.

    Given a list of names, matches any substring of one of these names. The
    string inclusion check is case-insensitive.

    Will match on the name of colitem, including the names of its parents.
    Only matches names of items which are either a :class:`Class` or a
    :class:`Function`.

    Additionally, matches on names in the 'extra_keyword_matches' set of
    any item, as well as names directly assigned to test functions.
    )_namesr@   itemr   r   c                 C   s   t  }dd l}| D ]}t||jrqt||jr"t|j|jr"q||j q|	|
  t|dd }|r>|	|j |	dd | D  | |S )Nr   functionc                 s   s    | ]}|j V  qd S Nr;   .0markr   r   r    	<genexpr>   s    z+KeywordMatcher.from_item.<locals>.<genexpr>)setpytestZ	listchain
isinstanceSessionZ	Directoryparentaddr;   updateZlistextrakeywordsgetattr__dict__iter_markers)clsrA   Zmapped_namesrJ   nodeZfunction_objr   r   r    	from_item   s    zKeywordMatcher.from_itemsubnamec                 C   s4   |  }dd | jD }|D ]	}||v r dS qdS )Nc                 s   s    | ]}|  V  qd S rC   )lower)rF   r;   r   r   r    rH      s    z*KeywordMatcher.__call__.<locals>.<genexpr>TF)rW   r@   )selfrV   namesr;   r   r   r    __call__   s   zKeywordMatcher.__call__N)rA   r   r   r?   __name__
__module____qualname____doc__	__slots__r   str__annotations__classmethodrU   boolrZ   r   r   r   r    r?      s   
 r?   itemsz
List[Item]c                 C   s|   |j j }|s
d S t|d}g }g }| D ]}|t|s%|| q|| q|r<|jj	|d || d d < d S d S )NzWrong expression passed to '-k're   )
r4   r#   lstrip_parse_expressionevaluater?   rU   appendhookpytest_deselected)re   r/   Zkeywordexprexpr	remaining
deselectedZcolitemr   r   r    deselect_by_keyword   s   
rp   c                   @   r>   )MarkMatcherzuA matcher for markers which are present.

    Tries to match on any marker names, attached to the given colitem.
    own_mark_namesrs   rA   r   r   c                 C   s   dd |  D }| |S )Nc                 S   s   h | ]}|j qS r   rD   rE   r   r   r    	<setcomp>   s    z(MarkMatcher.from_item.<locals>.<setcomp>)rR   )rS   rA   Z
mark_namesr   r   r    rU      s   zMarkMatcher.from_itemr;   c                 C   s
   || j v S rC   rr   )rX   r;   r   r   r    rZ      s   
zMarkMatcher.__call__N)rA   r   r   rq   r[   r   r   r   r    rq      s   
 rq   c                 C   sx   |j j}|sd S t|d}g }g }| D ]}|t|r#|| q|| q|r:|jj|d || d d < d S d S )NzWrong expression passed to '-m'rf   )	r4   r*   rh   ri   rq   rU   rj   rk   rl   )re   r/   Z	matchexprrm   rn   ro   rA   r   r   r    deselect_by_mark   s   
ru   rm   exc_messagec              
   C   s@   zt | W S  ty } zt| d|  d| d d }~ww )Nz: )r	   compiler
   r   )rm   rv   er   r   r    rh      s   rh   c                 C   s   t | | t| | d S rC   )rp   ru   )re   r/   r   r   r    pytest_collection_modifyitems  s   
ry   c                 C   s:   t j| jt< | t _| t}|dvrttd|d S )N)skipZxfailZfail_at_collectNr$   z9 must be one of skip, xfail or fail_at_collect but it is )r   _configstashold_mark_config_keyr5   r   r   )r/   Zempty_parametersetr   r   r    pytest_configure  s   
r~   c                 C   s   | j td t_d S rC   )r|   getr}   r   r{   )r/   r   r   r    pytest_unconfigure  s   r   )0r_   dataclassestypingr   r   r   r   r   r   
expressionr	   r
   
structuresr   r   r   r   r   r   r   r3   r   r   r   r   Z_pytest.config.argparsingr   Z_pytest.stashr   Z_pytest.nodesr   __all__r}   objectra   r   r.   intr=   	dataclassr?   rp   rq   ru   rh   ry   r~   r   r   r   r   r    <module>   sf    

* ;