o
    v&iZ                     @  sF  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
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 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j*d k rd d!l+m,Z, erd d"l-m.Z. d d#l/m0Z0 d$d% Z1G d&d' d'Z2dQd.d/Z3dRd6d7Z4dSd:d;Z5G d<d= d=e2Z6eG d>d? d?e2Z7G d@dA dAeZ8dTdEdFZ9dUdJdKZ:dVdLdMZ;dWdOdPZ<dS )X    )annotations)Iterable)Iterator)Mapping)SequenceN)StringIO)pprint)Any)cast)final)Literal)NoReturn)TYPE_CHECKING)ExceptionChainRepr)ExceptionInfo)ExceptionRepr)	ReprEntry)ReprEntryNative)ReprExceptionInfoReprFileLocation)ReprFuncArgs)
ReprLocalsReprTraceback)TerminalRepr)TerminalWriter)Config)	Collector)Item)fail)skip)      )BaseExceptionGroup)Self)CallInfoc              
   C  s^   z| j W S  ty.   | j}dj|d d d  }d|d |d ||d  | _ }| Y S w )Nz{}.{}.{}version_infor"   z[{}] {} -- Python {} {}idsysplatform
executable)_workerinfocacheAttributeError
workerinfoformat)nodedvers r3   U/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/_pytest/reports.pygetworkerinfoline1   s   
r5   c                   @  s  e Zd ZU ded< ded< ded< ded< d	ed
< ded< dCddZer)dDddZdEddZdFddZe	dGddZ
e	dGd d!Ze	dGd"d#Ze	dGd$d%Ze	dHd'd(Ze	dHd)d*Ze	dHd+d,Ze	dGd-d.Ze	dHd/d0Ze	dId1d2ZdJd8d9ZdKd;d<ZedLd@dAZdBS )M
BaseReport
str | Nonewhen"tuple[str, int | None, str] | NonelocationONone | ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalReprlongreprzlist[tuple[str, str]]sectionsstrnodeid&Literal['passed', 'failed', 'skipped']outcomekwr	   returnNonec                 K  s   | j | d S N)__dict__update)selfrB   r3   r3   r4   __init__G   s   zBaseReport.__init__keyc                 C  s   d S rE   r3   )rH   rJ   r3   r3   r4   __getattr__L   s    zBaseReport.__getattr__outr   c                 C  s   t | drt| j}|r|| | j}|d u rd S t |dr+tt|}|| d S zt|}W n t	y<   d}Y nw || d S )Nr/   
toterminalz<unprintable longrepr>)
hasattrr5   r/   liner<   r
   r   rM   r>   UnicodeEncodeError)rH   rL   worker_infor<   longrepr_terminalr2   r3   r3   r4   rM   N   s    




zBaseReport.toterminalprefixIterator[tuple[str, str]]c                 c  s*    | j D ]\}}||r||fV  qd S rE   )r=   
startswith)rH   rS   namecontentr3   r3   r4   get_sectionsb   s   

zBaseReport.get_sectionsc                 C  s.   t  }t|}d|_| | | }| S )zRead-only property that returns the full string representation of
        ``longrepr``.

        .. versionadded:: 3.0
        F)r   r   	hasmarkuprM   getvaluestrip)rH   filetwexcr3   r3   r4   longreprtextg   s   
zBaseReport.longreprtextc                 C     d dd | dD S )z_Return captured log lines, if log capturing is enabled.

        .. versionadded:: 3.5
        
c                 s      | ]\}}|V  qd S rE   r3   .0rS   rW   r3   r3   r4   	<genexpr>{       
z$BaseReport.caplog.<locals>.<genexpr>zCaptured logjoinrX   rH   r3   r3   r4   caplogu      
zBaseReport.caplogc                 C  r`   )zbReturn captured text from stdout, if capturing is enabled.

        .. versionadded:: 3.0
         c                 s  rb   rE   r3   rc   r3   r3   r4   re      rf   z'BaseReport.capstdout.<locals>.<genexpr>zCaptured stdoutrg   ri   r3   r3   r4   	capstdout   rk   zBaseReport.capstdoutc                 C  r`   )zbReturn captured text from stderr, if capturing is enabled.

        .. versionadded:: 3.0
        rl   c                 s  rb   rE   r3   rc   r3   r3   r4   re      rf   z'BaseReport.capstderr.<locals>.<genexpr>zCaptured stderrrg   ri   r3   r3   r4   	capstderr   rk   zBaseReport.capstderrboolc                 C  
   | j dkS )zWhether the outcome is passed.passedrA   ri   r3   r3   r4   rq         
zBaseReport.passedc                 C  rp   )zWhether the outcome is failed.failedrr   ri   r3   r3   r4   rt      rs   zBaseReport.failedc                 C  rp   )zWhether the outcome is skipped.skippedrr   ri   r3   r3   r4   ru      rs   zBaseReport.skippedc                 C  s   | j dd S )z3The path portion of the reported node, as a string.z::r   )r?   splitri   r3   r3   r4   fspath   s   zBaseReport.fspathc                 C  s   dS )a6  **Experimental** Whether this report should be counted towards the
        totals shown at the end of the test session: "1 passed, 1 failure, etc".

        .. note::

            This function is considered **experimental**, so beware that it is subject to changes
            even in patch releases.
        Tr3   ri   r3   r3   r4   count_towards_summary   s   
z BaseReport.count_towards_summaryc                 C  s   | j dur| j \}}}|S dS )a  **Experimental** The head line shown with longrepr output for this
        report, more commonly during traceback representation during
        failures::

            ________ Test.foo ________


        In the example above, the head_line is "Test.foo".

        .. note::

            This function is considered **experimental**, so beware that it is subject to changes
            even in patch releases.
        N)r:   )rH   _fspath_linenodomainr3   r3   r4   	head_line   s   
zBaseReport.head_lineconfigr   default_markupMapping[str, bool]tuple[str, Mapping[str, bool]]c                 C  sv   |j j| |d\}}}t|tr||fS t|tr1t|dkr1|\}}t|tr1t|tr1||fS td|d d S )N)reportr}      zSpytest_report_teststatus() hook (from a plugin) returned an invalid verbose value: z8.
Expected either a string or a tuple of (word, markup).)hookpytest_report_teststatus
isinstancer>   r   lenr   r    )rH   r}   r~   	_category_shortverbosewordmarkupr3   r3   r4   _get_verbose_word_with_markup   s   
z(BaseReport._get_verbose_word_with_markupdict[str, Any]c                 C  s   t | S )zReturn the contents of this report as a dict of builtin entries,
        suitable for serialization.

        This was originally the serialize_report() function from xdist (ca03269).

        Experimental method.
        )_report_to_jsonri   r3   r3   r4   _to_json   s   zBaseReport._to_json
reportdictdict[str, object]r%   c                 C  s   t |}| di |S )a  Create either a TestReport or CollectReport, depending on the calling class.

        It is the callers responsibility to know which class to pass here.

        This was originally the serialize_report() function from xdist (ca03269).

        Experimental method.
        Nr3   )_report_kwargs_from_json)clsr   kwargsr3   r3   r4   
_from_json   s   
zBaseReport._from_jsonN)rB   r	   rC   rD   )rJ   r>   rC   r	   rL   r   rC   rD   )rS   r>   rC   rT   rC   r>   )rC   ro   )rC   r7   )r}   r   r~   r   rC   r   )rC   r   )r   r   rC   r%   )__name__
__module____qualname____annotations__rI   r   rK   rM   rX   propertyr_   rj   rm   rn   rq   rt   ru   rw   rx   r|   r   r   classmethodr   r3   r3   r3   r4   r6   =   sH   
 



			


r6   	type_namer>   report_classtype[BaseReport]rC   r   c                 C  sp   d}t  }td|d td|  |d td| |d t||d td| |d td|d t| )Nz+https://github.com/pytest-dev/pytest/issueszd----------------------------------------------------------------------------------------------------)streamz,INTERNALERROR: Unknown entry type returned: zreport_name: zPlease report this bug at )r   r   RuntimeErrorrZ   )r   r   r   urlr   r3   r3   r4   _report_unserialization_failure   s   r   itemr   callCallInfo[None]excinfoExceptionInfo[BaseException]c                 C  s4   |j dkr| |}|S | j|| jddd}|S )Nr   tbstyleauto)style)r8   repr_failure_repr_failure_pyr}   	getoption)r   r   r   r<   r3   r3   r4   _format_failed_longrepr  s   

r   EExceptionInfo[BaseExceptionGroup[BaseException | BaseExceptionGroup]]tuple[str, int, str]c                 C  s   |  }|d usJ dtdd |jjD r3|  d d \}}|d us'J t||d f}d}nt|j|j	f}|j
}g }|jjD ]}t|dd pU|jrT|jd nd }	|	ra|	|vra||	 qD|rid	|n|}
g ||
R }|S )
N=There should always be a traceback entry for skipping a test.c                 s  s    | ]	}t |d dV  qdS )_use_item_locationFN)getattr)rd   r!   r3   r3   r4   re     s    
z?_format_exception_group_all_skipped_longrepr.<locals>.<genexpr>r      ru   msgr   z; )_getreprcrashallvalue
exceptions
reportinfoosrw   r>   pathlinenomessager   argsappendrh   )r   r   rr   rO   locdefault_msgmsgs	exceptionmreasonr<   r3   r3   r4   ,_format_exception_group_all_skipped_longrepr  s0   

r   c                   @  sL   e Zd ZU dZdZded< 					d'd(ddZd)dd Zed*d%d&Z	dS )+
TestReportzBasic test report object (also used for setup and teardown calls if
    they fail).

    Reports can contain arbitrary extra attributes.
    Fr>   wasxfailr3   r   Nr?   r:   tuple[str, int | None, str]keywordsMapping[str, Any]rA   r@   r<   r;   r8   $Literal['setup', 'call', 'teardown']r=   Iterable[tuple[str, str]]durationfloatstartstopuser_properties#Iterable[tuple[str, object]] | NonerC   rD   c                 K  s^   || _ || _|| _|| _|| _|| _t|pg | _t|| _|| _	|	| _
|
| _| j| d S rE   )r?   r:   r   rA   r<   r8   listr   r=   r   r   r   rF   rG   )rH   r?   r:   r   rA   r<   r8   r=   r   r   r   r   extrar3   r3   r4   rI   >  s   
zTestReport.__init__c              	   C  s(   d| j j d| jd| jd| jd	S )N< z when=	 outcome=>)	__class__r   r?   r8   rA   ri   r3   r3   r4   __repr__|  s   (zTestReport.__repr__r   r   r   r   c                 C  s  |j }|dks	J |j}|j}|j}dd |jD }|j}g }	|js'd}
d}nvt|ts1d}
|}nlt|jt	j
rqd}
| }|dusFJ d|jjrf| dd	 \}}|dusZJ t||d
 |jf}n7t|j|j|jf}n,t|jtr|jt	j
d
 du rd}
tttttB   |}t||}nd}
t|||}|jD ]\}}}|	d| d| |f q| |j|j||
|||	||||jdS )zCreate and fill a TestReport with standard item and call info.

        :param item: The item.
        :param call: The call info.
        collectc                 S  s   i | ]}|d qS )r   r3   rd   xr3   r3   r4   
<dictcomp>  s    z1TestReport.from_item_and_call.<locals>.<dictcomp>rq   Nrt   ru   r   r   r   z	Captured r   )r   )r8   r   r   r   r   r   r   r   r   r!   	Exceptionr   r   r   r   rw   r   r>   r   r   r$   rv   r
   BaseExceptionr   r   _report_sectionsr   r?   r:   r   )r   r   r   r8   r   r   r   r   r   r=   rA   r<   r   r   rO   rwhenrJ   rW   r3   r3   r4   from_item_and_call  sj   


zTestReport.from_item_and_call)r3   r   r   r   N)r?   r>   r:   r   r   r   rA   r@   r<   r;   r8   r   r=   r   r   r   r   r   r   r   r   r   rC   rD   r   )r   r   r   r   rC   r   )
r   r   r   __doc____test__r   rI   r   r   r   r3   r3   r3   r4   r   1  s   
 
>r   c                   @  s:   e Zd ZdZdZ	ddddZedddZdddZdS )CollectReportzSCollection report object.

    Reports can contain arbitrary extra attributes.
    r   r3   r?   r>   rA   r@   r<   r;   resultlist[Item | Collector] | Noner=   r   rC   rD   c                 K  s6   || _ || _|| _|pg | _t|| _| j| d S rE   )r?   rA   r<   r   r   r=   rF   rG   )rH   r?   rA   r<   r   r=   r   r3   r3   r4   rI     s   

zCollectReport.__init__r9   c                 C  s   | j d | j fS rE   )rw   ri   r3   r3   r4   r:     s   zCollectReport.locationc                 C  s"   d| j dt| j d| jdS )Nz<CollectReport z lenresult=r   r   )r?   r   r   rA   ri   r3   r3   r4   r     s   "zCollectReport.__repr__N)r3   )r?   r>   rA   r@   r<   r;   r   r   r=   r   rC   rD   )rC   r9   r   )	r   r   r   r   r8   rI   r   r:   r   r3   r3   r3   r4   r     s    !r   c                   @  s    e Zd ZdddZdd	d
ZdS )CollectErrorReprr   r>   rC   rD   c                 C  s
   || _ d S rE   )r<   )rH   r   r3   r3   r4   rI     s   
zCollectErrorRepr.__init__rL   r   c                 C  s   |j | jdd d S )NT)red)rO   r<   )rH   rL   r3   r3   r4   rM      s   zCollectErrorRepr.toterminalN)r   r>   rC   rD   r   )r   r   r   rI   rM   r3   r3   r3   r4   r     s    
r   r   CollectReport | TestReportdict[str, Any] | Nonec                 C  s*   t | ttB r|  }| jj|d< |S d S )N$report_type)r   r   r   r   r   r   )r   datar3   r3   r4   pytest_report_to_serializable  s
   r   r   r   !CollectReport | TestReport | Nonec                 C  sJ   d| v r#| d dkrt | S | d dkrt| S J d| d d S )Nr   r   r   Fz(Unknown report_type unserialize data: {})r   r   r   r.   )r   r3   r3   r4   pytest_report_from_serializable  s   

r   c                   s   ddddfd	d
ddd d fdd}| j  }t| jdr?t| jdr7t| jdr7|| |d< nt| j|d< n| j|d< |D ]}t|| tjrZt|| ||< qF|dkrbd||< qF|S )zReturn the contents of this report as a dict of builtin entries,
    suitable for serialization.

    This was originally the serialize_report() function from xdist (ca03269).
    entryReprEntry | ReprEntryNativerC   r   c                 S  sH   t | }| D ]\}}t|drt |||< q	t| j|d}|S )NrF   )typer   )dataclassesasdictitemsrN   r   r   )r   r   rJ   r   
entry_datar3   r3   r4   serialize_repr_entry$  s   

z-_report_to_json.<locals>.serialize_repr_entryreprtracebackr   c                   s&   t | } fdd| jD |d< |S )Nc                      g | ]} |qS r3   r3   r   r   r3   r4   
<listcomp>0      zE_report_to_json.<locals>.serialize_repr_traceback.<locals>.<listcomp>reprentries)r   r   r  )r   r   r  r3   r4   serialize_repr_traceback.  s
   


z1_report_to_json.<locals>.serialize_repr_traceback	reprcrashReprFileLocation | Noner   c                 S  s   | d ur	t | S d S rE   )r   r   )r  r3   r3   r4   serialize_repr_crash5  s   
z-_report_to_json.<locals>.serialize_repr_crashrepr6   c                   s   | j d usJ tt| j } |j|j|jd}t|tr<g |d< |jD ]\}}}|d 	| ||f q&|S d |d< |S )N)r  r   r=   chain)
r<   r
   r   r  r   r=   r   r   r
  r   )r	  r<   r   repr_traceback
repr_crashdescription)r  r  r3   r4   serialize_exception_longrepr=  s$   
	z5_report_to_json.<locals>.serialize_exception_longreprrM   r<   r   N)r   r   rC   r   )r   r   rC   r   )r  r  rC   r   )r	  r6   rC   r   )	rF   copyrN   r<   r>   r   r   PathLikerw   )r   r  r0   rV   r3   )r  r   r  r4   r     s&   




r   r   c                   s   fdd  fdd}ddd}d	 rnd
d	 v rndd	 v rn|d	 d }|d	 d
 }d	 d rVg }d	 d D ]\}}}| |||||f q?t|}	nt||d}	d	 d D ]}
|	j|
  qb|	d	< S )zReturn **kwargs that can be used to construct a TestReport or
    CollectReport instance.

    This was originally the serialize_report() function from xdist (ca03269).
    c                   s   | d }| d }|dkrGd }d }d }|d rt di |d }|d r,tdi |d }|d r8t|d d }t|d ||||d d	}|S |d
krSt|d }|S t|t  |S )Nr   r   r   reprfuncargsreprfileloc
reprlocalslinesr   )r  r  r  r  r   r   r3   )r   r   r   r   r   r   r   )r   r   
entry_typer  r  r  	reprentry)r   r3   r4   deserialize_repr_entrym  s2   z8_report_kwargs_from_json.<locals>.deserialize_repr_entryc                   s(    fdd| d D | d< t di | S )Nc                   r   r3   r3   r   r  r3   r4   r    r  zP_report_kwargs_from_json.<locals>.deserialize_repr_traceback.<locals>.<listcomp>r  r3   r   )repr_traceback_dictr  r3   r4   deserialize_repr_traceback  s   

z<_report_kwargs_from_json.<locals>.deserialize_repr_tracebackrepr_crash_dictr   c                 S  s   | d urt di | S d S )Nr3   r   )r  r3   r3   r4   deserialize_repr_crash  s   z8_report_kwargs_from_json.<locals>.deserialize_repr_crashr<   r  r   r
  )r   r  r=   N)r  r   )r   r   r   
addsection)r   r  r  r   r  r
  repr_traceback_datarepr_crash_datar  exception_infosectionr3   )r  r   r4   r   f  sF   

r   )r   r>   r   r   rC   r   )r   r   r   r   r   r   )r   r   r   r   rC   r   )r   r   rC   r   )r   r   rC   r   )r   r6   rC   r   )r   r   rC   r   )=
__future__r   collections.abcr   r   r   r   r   ior   r   r   systypingr	   r
   r   r   r   r   _pytest._code.coder   r   r   r   r   r   r   r   r   r   r   _pytest._ior   _pytest.configr   _pytest.nodesr   r   _pytest.outcomesr    r!   r'   exceptiongroupr$   typing_extensionsr%   _pytest.runnerr&   r5   r6   r   r   r   r   r   r   r   r   r   r   r3   r3   r3   r4   <module>   sj   
 
9

! 3


I