a
    /§»aà+  ã                   @   s"  d Z ddlZddl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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ddœdd„Z eddœdd„Z!eee"e
e#e$f dœdd„Z%ej&ddd�G dd„ dƒƒZ'ee	e' d œd!d"„Z(ej&ddd�G d#d$„ d$ƒƒZ)ee	e) d œd%d&„Z*ee# ƒ Z+ee	e)  ƒ Z,ee$ ƒ Z-edd'�edd œd(d)„ƒZ.edd*�eed+ d œd,d-„ƒZ/edd*�eed d.œd/d0„ƒZ0ee	e
e$e$e$f  d1œd2d3„Z1dS )4z-Support for skip/xfail functions and markers.é    N)ÚMapping)Ú	Generator)ÚOptional)ÚTuple)ÚType)ÚConfig)Úhookimpl)ÚParser)ÚMark)ÚItem)Úfail)Úskip)Úxfail)Ú
BaseReport)ÚCallInfo)ÚStoreKey)ÚparserÚreturnc                 C   s4   |   d¡}|jdddddd� | jdd	dd
d� d S )NZgeneralz
--runxfailÚ
store_trueÚrunxfailFz<report the results of xfail tests as if they were not marked)ÚactionÚdestÚdefaultÚhelpÚxfail_strictz\default for the strict parameter of xfail markers when not given explicitly (default: False)Úbool)r   Útype)ZgetgroupZ	addoptionZaddini)r   Úgroup© r   úJ/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/_pytest/skipping.pyÚpytest_addoption   s    
ûûr    )Úconfigr   c                    sp   | j jrHdd l‰ˆj‰ | j ‡ ‡fdd„¡ dd„ }tj|_tˆd|ƒ |  dd¡ |  dd	¡ |  dd
¡ d S )Nr   c                      s   t ˆdˆ ƒS )Nr   )Úsetattrr   ©ÚoldÚpytestr   r   Ú<lambda>4   ó    z"pytest_configure.<locals>.<lambda>c                  _   s   d S )Nr   )ÚargsÚkwargsr   r   r   Únop6   s    zpytest_configure.<locals>.nopr   Úmarkersz‘skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.a  skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipifaú  xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail)	Úoptionr   r%   r   Ú_cleanupÚappendÚ	Exceptionr"   Zaddinivalue_line)r!   r*   r   r#   r   Úpytest_configure.   s&    þþþr0   )ÚitemÚmarkÚ	conditionr   c              
   C   s  t |tƒ�rRttt| jdœ}t| jj| jd�ƒD ]&}t |t	ƒsLt
d |¡ƒ‚| |¡ q0t| dƒrp| | jj¡ z(d|j› d�}t||dƒ}t||ƒ}W n¶ työ } zFd|j d	| d	d
|jpÂd  d dg}	td |	¡dd� W Y d}~nbd}~0  t�yN } z@d|j d	| gt t|ƒ|¡¢}	td |	¡dd� W Y d}~n
d}~0 0 nbzt|ƒ}W nT t�y² } z:d|j gt t|ƒ|¡¢}	td |	¡dd� W Y d}~n
d}~0 0 |j dd¡}
|
du �rüt |tƒ�râd| }
nd|j d }t|dd� ||
fS )a.  Evaluate a single skipif/xfail condition.

    If an old-style string condition is given, it is eval()'d, otherwise the
    condition is bool()'d. If this fails, an appropriately formatted pytest.fail
    is raised.

    Returns (result, reason). The reason is only relevant if the result is True.
    )ÚosÚsysÚplatformr!   )r!   z<pytest_markeval_namespace() needs to return a dict, got {!r}Úobjú<z condition>ÚevalzError evaluating %r conditionz    ú r   ú^zSyntaxError: invalid syntaxÚ
F)ZpytraceNz*Error evaluating %r condition as a booleanÚreasonzcondition: zError evaluating %r: zDyou need to specify reason=STRING when using booleans as conditions.)Ú
isinstanceÚstrr4   r5   r6   r!   ÚreversedZihookZpytest_markeval_namespacer   Ú
ValueErrorÚformatÚupdateÚhasattrr7   Ú__globals__ÚnameÚcompiler9   ÚSyntaxErrorÚoffsetr   Újoinr/   Ú	tracebackÚformat_exception_onlyr   r   r)   Úget)r1   r2   r3   Úglobals_Ú
dictionaryÚfilenameZcondition_codeÚresultÚexcZmsglinesr=   Úmsgr   r   r   Úevaluate_conditionU   sl    
üÿ
ÿÿ
ü&þý*ÿþ(

ÿÿrT   T)ÚslotsÚfrozenc                   @   s   e Zd ZdZejed�ZdS )ÚSkipz$The result of evaluate_skip_marks().©r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚattrÚibr?   r=   r   r   r   r   rW       s   rW   )r1   r   c                 C   sÈ   | j dd�D ]n}d|jvr"|j}n|jd f}|sL|j dd¡}t|ƒ  S |D ](}t| ||ƒ\}}|rPt|ƒ    S qPq| j dd�D ]:}d|jv r¢|jd }n|jr´|jd }nd}t|ƒ  S d	S )
zDEvaluate skip and skipif marks on item, returning Skip if triggered.Zskipif©rF   r3   r=   Ú r   r   zunconditional skipN)Úiter_markersr)   r(   rM   rW   rT   )r1   r2   Ú
conditionsr=   r3   rQ   r   r   r   Úevaluate_skip_marks§   s&    

rc   c                   @   sP   e Zd ZdZejed�Zejed�Z	ejed�Z
ejeeee df  d�ZdS )ÚXfailz%The result of evaluate_xfail_marks().rX   .N)rY   rZ   r[   r\   r]   r^   r?   r=   r   ÚrunÚstrictr   r   r   ÚBaseExceptionÚraisesr   r   r   r   rd   Æ   s
   rd   c           	      C   s¾   | j dd�D ]¬}|j dd¡}|j d| j d¡¡}|j dd¡}d	|jvrT|j}n|jd	 f}|s„|j d
d¡}t||||ƒ  S |D ].}t| ||ƒ\}}|rˆt||||ƒ    S qˆqdS )z;Evaluate xfail marks on item, returning Xfail if triggered.r   r_   re   Trf   r   rh   Nr3   r=   r`   )ra   r)   rM   r!   Zgetinir(   rd   rT   )	r1   r2   re   rf   rh   rb   r=   r3   rQ   r   r   r   Úevaluate_xfail_marksÐ   s    
ri   )Ztryfirstc                 C   s\   t | ƒ}|d u| jt< |r$t|jƒ t| ƒ | jt< }|rX| jjj	sX|j
sXtd|j ƒ d S ©Nz	[NOTRUN] )rc   Ú_storeÚskipped_by_mark_keyr   r=   ri   Úxfailed_keyr!   r,   r   re   r   )r1   ÚskippedÚxfailedr   r   r   Úpytest_runtest_setupð   s    
rp   )Zhookwrapper)NNNc                 c   s|   | j  td ¡}|d u r(t| ƒ | j t< }|rJ| jjjsJ|jsJtd|j	 ƒ d V  | j  td ¡}|d u rxt| ƒ | j t< }d S rj   )
rk   rM   rm   ri   r!   r,   r   re   r   r=   )r1   ro   r   r   r   Úpytest_runtest_callü   s    rq   )r1   Úcallc           
      c   s’  d V }|  ¡ }| j td ¡}t| jv rZ|jdkrZ| jt }|rLd|› �|_nd|_d|_nÊ| jj	j
rfn¾|jr¦t|jjtjƒr¦|jjjd usŽJ ‚d|jjj |_d|_n~|j�s$|�r$|jrî|j}|d urÞt|jj|ƒsÞd|_nd|_|j|_n6|jdk�r$|j�rd|_d|j |_nd|_|j|_| j td	¡�rŽ|j�rŽt|jƒtu �rŽ|j\}}}|  ¡ d d
… \}}	|	d u�szJ ‚t|ƒ|	d |f|_d S )Nrr   zUnexpected success: zUnexpected successÚfailedzreason: rn   z[XPASS(strict)] ÚpassedTé   é   )Z
get_resultrk   rM   rm   Úunexpectedsuccess_keyÚwhenZlongreprÚoutcomer!   r,   r   Úexcinfor>   Úvaluer   r/   rS   Úwasxfailrn   rh   r=   rf   rl   r   ÚtupleZ
reportinfor?   )
r1   rr   ry   Úrepro   r=   rh   Ú_rP   Úliner   r   r   Úpytest_runtest_makereport  sL    


ÿþýr�   )Úreportr   c                 C   s"   t | dƒr| jrdS | jrdS d S )Nr|   )ro   ÚxZXFAIL)ZxpassedÚXZXPASS)rD   rn   rt   )r‚   r   r   r   Úpytest_report_teststatus>  s    
r…   )2r\   r4   r6   r5   rK   Úcollections.abcr   Útypingr   r   r   r   r]   Z_pytest.configr   r   Z_pytest.config.argparsingr	   Z_pytest.mark.structuresr
   Z_pytest.nodesr   Z_pytest.outcomesr   r   r   Z_pytest.reportsr   Z_pytest.runnerr   Z_pytest.storer   r    r0   Úobjectr   r?   rT   ÚsrW   rc   rd   ri   rl   rm   rw   rp   rq   r�   r…   r   r   r   r   Ú<module>   sP   'K	

0