a
    !f!                     @   s.  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rddlmZ g dZeee   Z ddde!eeeeeef  f ee" edddZ#edd d!d"Z$ed#d$eeee%ef  d%d&d'Z&ej'G d(d) d)Z(d*edd+d,d-Z)ej'G d.d/ d/Z*d*edd+d0d1Z+e"e"e
d2d3d4Z,d*edd+d5d6Z-edd%d7d8Z.edd%d9d: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   V/var/www/html/python-backend/venv/lib/python3.9/site-packages/_pytest/mark/__init__.pyr   +   s    r   )parserr   c                 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Markers for test functionsZlinelistz&Default marker for empty parametersets)ZgetgroupZ
_addoptionZ	addoptionZaddinir   )r!   groupr   r   r    pytest_addoptionF   s0    

r.   T)Ztryfirst)configr   c                 C   s   dd l }| jjr|   |j| }| dD ]T}|dd}|d }t|dkrZ|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_mainp   s    

r=   c                   @   sF   e Zd ZU dZdZee ed< edd dddZ	ee
d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?   r   itemr   c                 C   s~   t  }dd l}| D ]}t||js||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>       z+KeywordMatcher.from_item.<locals>.<genexpr>)setpytestZ	listchain
isinstanceSessionaddr;   updateZlistextrakeywordsgetattr__dict__iter_markers)clsrA   Zmapped_namesrK   nodeZfunction_objr   r   r    	from_item   s    zKeywordMatcher.from_item)subnamer   c                 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      rI   z*KeywordMatcher.__call__.<locals>.<genexpr>TF)rW   r?   )selfrV   namesr;   r   r   r    __call__   s    zKeywordMatcher.__call__N__name__
__module____qualname____doc__	__slots__r   str__annotations__classmethodrU   boolrZ   r   r   r   r    r>      s   
r>   z
List[Item])itemsr/   r   c                 C   sx   |j j }|sd S t|d}g }g }| D ]*}|t|sJ|| q*|| q*|rt|jj	|d || d d < 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                   @   sF   e Zd ZU dZdZee ed< edd dddZ	ee
dd	d
ZdS )MarkMatcherzuA matcher for markers which are present.

    Tries to match on any marker names, attached to the given colitem.
    own_mark_namesrs   r   r@   c                 C   s   dd |  D }| |S )Nc                 S   s   h | ]
}|j qS r   rD   rE   r   r   r    	<setcomp>   rI   z(MarkMatcher.from_item.<locals>.<setcomp>)rR   )rS   rA   Z
mark_namesr   r   r    rU      s    zMarkMatcher.from_item)r;   r   c                 C   s
   || j v S rC   rr   )rX   r;   r   r   r    rZ      s    zMarkMatcher.__call__Nr[   r   r   r   r    rq      s   
rq   c                 C   st   |j j}|sd S t|d}g }g }| D ]*}|t|rF|| q&|| q&|rp|jj|d || d d < 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_messager   c              
   C   sP   zt | W S  tyJ } z&t| d|  d| d W Y d }~n
d }~0 0 d S )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   s8   t j| jt< | t _| t}|dvr4tdt|d S )N)skipZxfailZfail_at_collectNr$   zA{!s} must be one of skip, xfail or fail_at_collect but it is {!r})r   _configstashold_mark_config_keyr5   r   r   format)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   Z
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>   s^   
*4