o
    ZhQ                     @   s  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 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rd d$l+m,Z, d%d& Z-ed'd(d)Z.G d*d( d(Z/d+e0d,ee/ d-efd.d/Z1e	G d0d1 d1e/Z2e	G d2d3 d3e/Z3G d4d5 d5e!Z4d6ee3e2f d-eee0ef  fd7d8Z5d9ee0ef d-eee3e2f  fd:d;Z6d6e/d-ee0ef fd<d=Z7d>ee0ef d-ee0ef fd?d@Z8dS )A    N)StringIO)pprint)Any)cast)Dict)final)Iterable)Iterator)List)Literal)Mapping)NoReturn)Optional)Tuple)Type)TYPE_CHECKING)TypeVar)Union)ExceptionChainRepr)ExceptionInfo)ExceptionRepr)	ReprEntry)ReprEntryNative)ReprExceptionInfoReprFileLocation)ReprFuncArgs)
ReprLocalsReprTraceback)TerminalRepr)TerminalWriter)Config)	Collector)Item)skip)CallInfoc              
   C   s^   z| j W S  ty.   | j}dj|d d d  }d|d |d ||d  | _ }| Y S w )Nz{}.{}.{}version_info   z[{}] {} -- Python {} {}idZsysplatform
executable)Z_workerinfocacheAttributeErrorZ
workerinfoformat)nodedvers r1   F/var/www/html/lang_env/lib/python3.10/site-packages/_pytest/reports.pygetworkerinfoline-   s   
r3   _R
BaseReport)boundc                   @   s  e Zd ZU ee ed< eeeee ef  ed< ede	e
 eeeef eef ed< eeeef  ed< eed< ed ed< d	ed
dfddZerRded
efddZded
dfddZded
eeeef  fddZed
efddZed
efddZed
efddZed
efddZed
efddZed
efd d!Zed
efd"d#Zed
efd$d%Zed
efd&d'Z ed
ee fd(d)Z!d*e"fd+d,Z#d
e$eef fd-d.Z%e&d/e'e( d0e$ee)f d
e(fd1d2Z*dS )3r5   whenlocationNlongreprsectionsnodeidpassedfailedskippedoutcomekwreturnc                 K   s   | j | d S N)__dict__update)selfrA   r1   r1   r2   __init__F   s   zBaseReport.__init__keyc                 C   s   d S rC   r1   )rF   rH   r1   r1   r2   __getattr__K   s   zBaseReport.__getattr__outc                 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>)
hasattrr3   r-   liner9   r   r    rK   strUnicodeEncodeError)rF   rJ   Zworker_infor9   Zlongrepr_terminalr0   r1   r1   r2   rK   N   s    




zBaseReport.toterminalprefixc                 c   s*    | j D ]\}}||r||fV  qd S rC   )r:   
startswith)rF   rP   namecontentr1   r1   r2   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!   Z	hasmarkuprK   getvaluestrip)rF   fileZtwexcr1   r1   r2   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 rC   r1   .0rP   rS   r1   r1   r2   	<genexpr>{       
z$BaseReport.caplog.<locals>.<genexpr>zCaptured logjoinrT   rF   r1   r1   r2   caplogu      
zBaseReport.caplogc                 C   rZ   )zbReturn captured text from stdout, if capturing is enabled.

        .. versionadded:: 3.0
         c                 s   r\   rC   r1   r]   r1   r1   r2   r_      r`   z'BaseReport.capstdout.<locals>.<genexpr>zCaptured stdoutra   rc   r1   r1   r2   	capstdout   re   zBaseReport.capstdoutc                 C   rZ   )zbReturn captured text from stderr, if capturing is enabled.

        .. versionadded:: 3.0
        rf   c                 s   r\   rC   r1   r]   r1   r1   r2   r_      r`   z'BaseReport.capstderr.<locals>.<genexpr>zCaptured stderrra   rc   r1   r1   r2   	capstderr   re   zBaseReport.capstderrc                 C   
   | j dkS )zWhether the outcome is passed.r=   r@   rc   r1   r1   r2   r=         
zBaseReport.passedc                 C   ri   )zWhether the outcome is failed.r>   rj   rc   r1   r1   r2   r>      rk   zBaseReport.failedc                 C   ri   )zWhether the outcome is skipped.r?   rj   rc   r1   r1   r2   r?      rk   zBaseReport.skippedc                 C   s   | j dd S )z3The path portion of the reported node, as a string.z::r   )r;   splitrc   r1   r1   r2   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.
        Tr1   rc   r1   r1   r2   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)r8   )rF   rm   linenodomainr1   r1   r2   	head_line   s   
zBaseReport.head_lineconfigc                 C   s   |j j| |d\}}}|S )N)reportrr   )hookZpytest_report_teststatus)rF   rr   Z	_categoryZ_shortverboser1   r1   r2   _get_verbose_word   s   zBaseReport._get_verbose_wordc                 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_jsonrc   r1   r1   r2   _to_json   s   zBaseReport._to_jsoncls
reportdictc                 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.
        Nr1   )_report_kwargs_from_json)ry   rz   kwargsr1   r1   r2   
_from_json   s   
zBaseReport._from_json)+__name__
__module____qualname__r   rN   __annotations__r   intr   r   BaseExceptionr    r
   r   r   rG   r   rI   r!   rK   r	   rT   propertyrY   rd   rg   rh   boolr=   r>   r?   rm   rn   rq   r"   rv   r   rx   classmethodr   r4   objectr}   r1   r1   r1   r2   r5   <   sL   
 			
(	type_namereport_classrB   c                 C   sj   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: %szreport_name: %szPlease report this bug at %s)r   r   RuntimeErrorrU   )r   r   rz   urlr   r1   r1   r2   _report_unserialization_failure   s   r   c                   @   s   e Zd ZU dZdZeed< 					ddedeeee	 ef d	e
eef d
ed dedee eee	ef eef ded deeeef  dedededeeeeef   ddfddZdefddZededddd f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.
    FZwasxfailr1   r   Nr;   r8   keywordsr@   r<   r9   r7   )setupcallZteardownr:   durationstartstopuser_propertiesrB   c                 K   s^   || _ || _|| _|| _|| _|| _t|pg | _t|| _|| _	|	| _
|
| _| j| d S rC   )r;   r8   r   r@   r9   r7   listr   r:   r   r   r   rD   rE   )rF   r;   r8   r   r@   r9   r7   r:   r   r   r   r   extrar1   r1   r2   rG     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;   r7   r@   rc   r1   r1   r2   __repr__=  s   (zTestReport.__repr__itemr   zCallInfo[None]c                 C   sd  |j }|dks	J |j}|j}|j}dd |jD }|j}g }	|js'd}
d}nct|ts1d}
|}nYt|jt	j
rqd}
| }|dusFJ d|jjrf| dd	 \}}|dusZJ t||d
 |jf}n$t|j|j|jf}nd}
|j dkr~||}n|j||jddd}|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 )   r1   r^   xr1   r1   r2   
<dictcomp>M  s    z1TestReport.from_item_and_call.<locals>.<dictcomp>r=   Nr>   r?   z=There should always be a traceback entry for skipping a test.   r   r   Ztbstyleauto)stylez	Captured r   )r   )r7   r   r   r   r   excinfo
isinstancer   valuer%   	ExceptionZ_getreprcrashZ_use_item_locationZ
reportinfoosrm   messagerN   pathro   Zrepr_failureZ_repr_failure_pyrr   Z	getoptionZ_report_sectionsappendr;   r8   r   )ry   r   r   r7   r   r   r   r   r   r:   r@   r9   rr   rM   ZrwhenrH   rS   r1   r1   r2   from_item_and_call@  s^   


zTestReport.from_item_and_call)r1   r   r   r   N)r~   r   r   __doc__Z__test__rN   r   r   r   r   r   r   r   r   r   r   r    r   floatr   rG   r   r   r$   r   r1   r1   r1   r2   r      sN   
 
	

<r   c                   @   s   e Zd ZdZdZ	ddedddedee e	ee
ef eef d	eeeeef   d
ee	eef  ddfddZedee	eee
 ef  fddZdefddZdS )CollectReportzSCollection report object.

    Reports can contain arbitrary extra attributes.
    r   r1   r;   r@   z&Literal['passed', 'failed', 'skipped']r9   Nresultr:   rB   c                 K   s6   || _ || _|| _|pg | _t|| _| j| d S rC   )r;   r@   r9   r   r   r:   rD   rE   )rF   r;   r@   r9   r   r:   r   r1   r1   r2   rG     s   

zCollectReport.__init__c                 C   s   | j d | j fS rC   )rm   rc   r1   r1   r2   r8     s   zCollectReport.locationc                 C   s"   d| j dt| j d| jdS )Nz<CollectReport z lenresult=r   r   )r;   lenr   r@   rc   r1   r1   r2   r     s   "zCollectReport.__repr__)r1   )r~   r   r   r   r7   rN   r   r   r   r   r   r    r   r
   r$   r#   r   rG   r   r8   r   r1   r1   r1   r2   r     s0    


r   c                   @   s0   e Zd ZdeddfddZdeddfddZdS )	CollectErrorReprmsgrB   Nc                 C   s
   || _ d S rC   )r9   )rF   r   r1   r1   r2   rG     s   
zCollectErrorRepr.__init__rJ   c                 C   s   |j | jdd d S )NT)red)rM   r9   )rF   rJ   r1   r1   r2   rK     s   zCollectErrorRepr.toterminal)r~   r   r   rN   rG   r!   rK   r1   r1   r1   r2   r     s    r   rs   c                 C   s*   t | ttfr|  }| jj|d< |S d S )N$report_type)r   r   r   rx   r   r~   )rs   datar1   r1   r2   pytest_report_to_serializable  s
   r   r   c                 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   r1   r1   r2   pytest_report_from_serializable  s   

r   c                    s  dt ttf dtttf fdddtdtttf ffdddtt dttttf  fd	d
 dt	dtttf f fdd}| j
 }t| jdrgt| jdr_t| jdr_|| |d< nt| j|d< n| j|d< |D ]}t|| tjrt|| ||< qn|dkrd||< qn|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).
    entryrB   c                 S   sH   t | }| D ]\}}t|drt |||< q	t| j|d}|S )NrD   )typer   )dataclassesasdictitemsrL   r   r~   )r   r   rH   r   
entry_datar1   r1   r2   serialize_repr_entry  s   

z-_report_to_json.<locals>.serialize_repr_entryreprtracebackc                    s&   t | } fdd| jD |d< |S )Nc                       g | ]} |qS r1   r1   r   r   r1   r2   
<listcomp>      zE_report_to_json.<locals>.serialize_repr_traceback.<locals>.<listcomp>reprentries)r   r   r   )r   r   r   r1   r2   serialize_repr_traceback  s
   


z1_report_to_json.<locals>.serialize_repr_traceback	reprcrashc                 S   s   | d ur	t | S d S rC   )r   r   )r   r1   r1   r2   serialize_repr_crash  s   
z-_report_to_json.<locals>.serialize_repr_crashrepc                    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)
r9   r   r   r   r   r:   r   r   r   r   )r   r9   r   Zrepr_tracebackZ
repr_crashdescription)r   r   r1   r2   serialize_exception_longrepr  s$   
	z5_report_to_json.<locals>.serialize_exception_longreprrK   r9   r   N)r   r   r   r   rN   r   r   r   r   r5   rD   copyrL   r9   r   r   PathLikerm   )rs   r   r.   rR   r1   )r   r   r   r2   rw     s6   




 

rw   rz   c                    s   fdd  fdd}dt tttf  fdd}d rvd	d v rvd
d v rv|d d
 }|d d	 }d d r^g }d d D ]\}}}||||||f qGt|}	nt||d}	d d D ]}
|	j|
  qj|	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   r1   )r   r   r   r   r   r   r   )r   r   Z
entry_typer   r   r   Z	reprentry)rz   r1   r2   deserialize_repr_entry%  s2   z8_report_kwargs_from_json.<locals>.deserialize_repr_entryc                    s(    fdd| d D | d< t di | S )Nc                    r   r1   r1   r   r   r1   r2   r   A  r   zP_report_kwargs_from_json.<locals>.deserialize_repr_traceback.<locals>.<listcomp>r   r1   r   )Zrepr_traceback_dictr   r1   r2   deserialize_repr_traceback@  s   

z<_report_kwargs_from_json.<locals>.deserialize_repr_tracebackrepr_crash_dictc                 S   s   | d urt di | S d S )Nr1   r   )r   r1   r1   r2   deserialize_repr_crashF  s   z8_report_kwargs_from_json.<locals>.deserialize_repr_crashr9   r   r   r   )r   r   r:   )r   r   rN   r   r   r   r   Z
addsection)rz   r   r   r   r   r   Zrepr_traceback_dataZrepr_crash_datar   Zexception_infosectionr1   )r   rz   r2   r{     sD   
	r{   )9r   ior   r   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   Z_pytest._code.coder   r   r   r   r   r   r   r   r   r   r    Z_pytest._ior!   Z_pytest.configr"   Z_pytest.nodesr#   r$   Z_pytest.outcomesr%   Z_pytest.runnerr&   r3   r4   r5   rN   r   r   r   r   r   r   rw   r{   r1   r1   r1   r2   <module>   s    +
 1



&I