U
    `»{j[$  ã                   @  s&  d Z ddlmZ ddl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! dddddd gZ"ee	e  ƒ Z#d!dd"œd#d$d%dd&œd'd(„Z$d)d*d+œd,d-„Z%ed.d/�d0d1d2œd3d4„ƒZ&ej'G d5d6„ d6ƒƒZ(d7d0d*d8œd9d:„Z)ej'G d;d<„ d<ƒƒZ*d7d0d*d8œd=d>„Z+d?d?d@dAœdBdC„Z,d7d0d*d8œdDdE„Z-d0d*d2œdFdG„Z.d0d*d2œdHdI„Z/dS )Jz=Generic mechanism for marking and selecting python functions.é    )ÚannotationsN)ÚAbstractSet)Ú
Collection)ÚIterable)ÚOptional)ÚTYPE_CHECKINGé   )Ú
Expression)Ú
ParseError)ÚEMPTY_PARAMETERSET_OPTION)Úget_empty_parameterset_mark)ÚMark)ÚMARK_GEN)ÚMarkDecorator)ÚMarkGenerator)ÚParameterSet)ÚConfig)ÚExitCode)Úhookimpl)Ú
UsageError)ÚNOT_SET)ÚParser)ÚStashKey)ÚItemr   r   r   r   r   r   © ©ÚmarksÚidÚobjectz0MarkDecorator | Collection[MarkDecorator | Mark]z
str | None)Ú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   úT/var/www/html/bwave/python/venv/lib/python3.8/site-packages/_pytest/mark/__init__.pyr!   0   s    r!   r   ÚNone)Ú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 evaluable 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_addoptionK   s0    
úú
ýr1   T)Ztryfirstr   zint | ExitCode | None)Úconfigr    c                 C  s˜   dd l }| jjr”|  ¡  |j | ¡}|  d¡D ]X}| dd¡}|d }t|ƒdkrZ|d nd}|j	d|› d�dd	� | 
|¡ | 
¡  q.|  ¡  dS d S )
Nr   r/   ú:r   é   r'   z@pytest.mark.T)Úbold)Ú_pytest.configÚoptionr/   Z_do_configurer2   Zcreate_terminal_writerÚgetiniÚsplitÚlenÚwriteÚlineZ_ensure_unconfigure)r2   Z_pytestZtwr<   ÚpartsÚnameÚrestr   r   r"   Úpytest_cmdline_mainu   s    

r@   c                   @  sD   e Zd ZU dZdZded< edd dœdd„ƒZd	d
d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.
    )Ú_nameszAbstractSet[str]rB   r   )Úitemr    c                 C  sœ   t ƒ }dd l}| ¡ D ]:}t||jƒr(qt||jƒrDt|j|jƒrDq| |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)ÚclsrC   Zmapped_namesrJ   ÚnodeZfunction_objr   r   r"   Ú	from_itemœ   s"     ÿzKeywordMatcher.from_itemÚstrústr | int | bool | NoneÚbool)ÚsubnameÚkwargsr    c                K  s@   |rt dƒ‚| ¡ }dd„ | jD ƒ}|D ]}||kr( dS q(dS )Nz3Keyword expressions do not support call parameters.c                 s  s   | ]}|  ¡ V  qd S rE   )Úlower)rF   r>   r   r   r"   rH   ¿   s     z*KeywordMatcher.__call__.<locals>.<genexpr>TF)r   r[   rB   )ÚselfrY   rZ   Únamesr>   r   r   r"   Ú__call__»   s    zKeywordMatcher.__call__N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú__annotations__ÚclassmethodrU   r^   r   r   r   r"   rA   ‰   s   
rA   z
list[Item])Úitemsr2   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'©rf   )
r7   r&   ÚlstripÚ_parse_expressionÚevaluaterA   rU   ÚappendÚhookÚpytest_deselected)rf   r2   ZkeywordexprÚexprÚ	remainingÚ
deselectedZcolitemr   r   r"   Údeselect_by_keywordÇ   s    
rq   c                   @  sD   e Zd ZU dZdZded< edd dœdd„ƒZd	d
d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_name_mappingzdict[str, list[Mark]]rs   zIterable[Mark])r/   r    c                 C  s,   t  t¡}|D ]}||j  |¡ q| |ƒS rE   )ÚcollectionsÚdefaultdictÚlistr>   rk   )rS   r/   Zmark_name_mappingrG   r   r   r"   Úfrom_markersæ   s    
zMarkMatcher.from_markersrV   rW   rX   )r>   rZ   r    c                  sD   | j  |g ¡ }sdS |D ]$‰ t‡ fdd„| ¡ D ƒƒr dS qdS )NFc                 3  s$   | ]\}}ˆ j  |t¡|kV  qd S rE   )rZ   Úgetr   )rF   ÚkÚv©rG   r   r"   rH   ò   s     z'MarkMatcher.__call__.<locals>.<genexpr>T)rs   rx   Úallrf   )r\   r>   rZ   Úmatchesr   r{   r"   r^   í   s    zMarkMatcher.__call__N)	r_   r`   ra   rb   rc   rd   re   rw   r^   r   r   r   r"   rr   Û   s   
rr   c                 C  sx   |j j}|sd S t|dƒ}g }g }| D ].}| t | ¡ ¡¡rJ| |¡ q&| |¡ q&|rt|jj	|d� || d d …< d S )NzWrong expression passed to '-m'rg   )
r7   r-   ri   rj   rr   rw   rR   rk   rl   rm   )rf   r2   Z	matchexprrn   ro   rp   rC   r   r   r"   Údeselect_by_markø   s    
r~   rV   r	   )rn   Úexc_messager    c              
   C  sN   zt  | ¡W S  tk
rH } zt|› d| › d|› �ƒd ‚W 5 d }~X Y nX d S )Nz: )r	   Úcompiler
   r   )rn   r   Úer   r   r"   ri   
  s    ri   c                 C  s   t | |ƒ t| |ƒ d S rE   )rq   r~   )rf   r2   r   r   r"   Úpytest_collection_modifyitems  s    
r‚   c                 C  s:   t j| jt< | t _|  t¡}|dkr6t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_keyr8   r   r   )r2   Zempty_parametersetr   r   r"   Úpytest_configure  s    
ÿr‡   c                 C  s   | j  td ¡t_d S rE   )r…   rx   r†   r   r„   )r2   r   r   r"   Úpytest_unconfigure#  s    rˆ   )0rb   Ú
__future__r   rt   ÚdataclassesÚtypingr   r   r   r   r   Ú
expressionr	   r
   Ú
structuresr   r   r   r   r   r   r   r6   r   r   r   r   Z_pytest.config.argparsingr   r   Z_pytest.stashr   Z_pytest.nodesr   Ú__all__r†   r!   r1   r@   Ú	dataclassrA   rq   rr   r~   ri   r‚   r‡   rˆ   r   r   r   r"   Ú<module>   sd   ú
ý*=