a
    !f'                     @   s
  d Z ddl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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G dd dZ'ee
e' d d!d"Z(ej&ddG d#d$ d$Z)ee
e) d d%d&Z*e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Z.ee
ee$e$e$f  d1d2d3Z/d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)StashKey)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   Q/var/www/html/python-backend/venv/lib/python3.9/site-packages/_pytest/skipping.pypytest_addoption   s    
r    )configr   c                    sn   | j jrFdd l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>3       z"pytest_configure.<locals>.<lambda>c                  _   s   d S )Nr   )argskwargsr   r   r   nop5   s    zpytest_configure.<locals>.nopr   markerszskip(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/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/reference.html#pytest-mark-xfail)optionr   r%   r   Zadd_cleanup	Exceptionr"   Zaddinivalue_line)r!   r*   r   r#   r   pytest_configure-   s&    r.   )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pd  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 rt |trd| }
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strr2   r3   r4   r!   reversedZihookZpytest_markeval_namespacer   
ValueErrorformatupdatehasattrr5   __globals__namecompiler7   SyntaxErroroffsetr   joinr-   	tracebackformat_exception_onlyr   r   r)   get)r/   r0   r1   globals_
dictionaryfilenameZcondition_coderesultexcZmsglinesr;   msgr   r   r   evaluate_conditionT   sl    


&*(

rR   T)frozenc                   @   s   e Zd ZU dZdZeed< dS )Skipz$The result of evaluate_skip_marks().zunconditional skipr;   N)__name__
__module____qualname____doc__r;   r=   __annotations__r   r   r   r   rT      s   
rT   )r/   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 ]T}zt|ji |jW   S  ty } ztt|d dW Y d}~qd}~0 0 qdS )	zDEvaluate skip and skipif marks on item, returning Skip if triggered.ZskipifrD   r1   r;    r   z& - maybe you meant pytest.mark.skipif?N)iter_markersr)   r(   rK   rT   rR   	TypeErrorr=   )r/   r0   
conditionsr;   r1   rO   er   r   r   evaluate_skip_marks   s"    
*r`   c                   @   sF   e Zd ZU dZdZeed< eed< eed< ee	e
e df  ed< dS )	Xfailz%The result of evaluate_xfail_marks().)r;   runstrictraisesr;   rb   rc   .rd   N)rU   rV   rW   rX   	__slots__r=   rY   r   r   r   r   BaseExceptionr   r   r   r   ra      s   
ra   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| ||\}}|rt||||    S qqdS )z;Evaluate xfail marks on item, returning Xfail if triggered.r   rZ   rb   Trc   r   rd   Nr1   r;   r[   )r\   r)   rK   r!   Zgetinir(   ra   rR   )	r/   r0   rb   rc   rd   r^   r;   r1   rO   r   r   r   evaluate_xfail_marks   s    
rg   )Ztryfirstc                 C   sT   t | }|rtj|jddt|  | jt< }|rP| jjj	sP|j
sPtd|j  d S )NT)Z_use_item_location	[NOTRUN] )r`   r   r-   r;   rg   stashxfailed_keyr!   r,   r   rb   r   )r/   skippedxfailedr   r   r   pytest_runtest_setup   s    rm   )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 )Nrh   )
ri   rK   rj   rg   r!   r,   r   rb   r   r;   )r/   rl   r   r   r   pytest_runtest_call   s    rn   )r/   callc                 c   s   d V }|  }| jtd }| jjjr(n|jrht|jj	t
jrh|jj	jd usPJ d|jj	j |_d|_nv|js|r|jr|j}|d urt|jj	|sd|_qd|_|j|_n2|jdkr|jrd|_d|j |_nd|_|j|_d S )Nzreason: rk   failedro   z[XPASS(strict)] passed)Z
get_resultri   rK   rj   r!   r,   r   excinfor<   valuer   r-   rQ   wasxfailoutcomerk   rd   r;   whenrc   Zlongrepr)r/   ro   ru   reprl   rd   r   r   r   pytest_runtest_makereport  s,    



rx   )reportr   c                 C   s"   t | dr| jrdS | jrdS d S )Nrt   )rl   xZXFAIL)ZxpassedXZXPASS)rB   rk   rq   )ry   r   r   r   pytest_report_teststatus#  s    
r|   )0rX   dataclassesr2   r4   r3   rI   collections.abcr   typingr   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.stashr   r    r.   objectr   r=   rR   	dataclassrT   r`   ra   rg   rj   rm   rn   rx   r|   r   r   r   r   <module>   sL   'K


