o
    hgQ                     @   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 {} {}idsysplatform
executable)_workerinfocacheAttributeError
workerinfoformat)nodedvers r4   H/var/www/html/wtlms/venv/lib/python3.10/site-packages/_pytest/reports.pygetworkerinfoline-   s   
r6   _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 )3r8   whenlocationNlongreprsectionsnodeidpassedfailedskippedoutcomekwreturnc                 K   s   | j | d S N)__dict__update)selfrD   r4   r4   r5   __init__F   s   zBaseReport.__init__keyc                 C   s   d S rF   r4   )rI   rK   r4   r4   r5   __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 )Nr0   
toterminalz<unprintable longrepr>)
hasattrr6   r0   liner<   r   r    rN   strUnicodeEncodeError)rI   rM   worker_infor<   longrepr_terminalr3   r4   r4   r5   rN   N   s    




zBaseReport.toterminalprefixc                 c   s*    | j D ]\}}||r||fV  qd S rF   )r=   
startswith)rI   rU   namecontentr4   r4   r5   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!   	hasmarkuprN   getvaluestrip)rI   filetwexcr4   r4   r5   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 rF   r4   .0rU   rX   r4   r4   r5   	<genexpr>{       
z$BaseReport.caplog.<locals>.<genexpr>zCaptured logjoinrY   rI   r4   r4   r5   caplogu      
zBaseReport.caplogc                 C   ra   )zbReturn captured text from stdout, if capturing is enabled.

        .. versionadded:: 3.0
         c                 s   rc   rF   r4   rd   r4   r4   r5   rf      rg   z'BaseReport.capstdout.<locals>.<genexpr>zCaptured stdoutrh   rj   r4   r4   r5   	capstdout   rl   zBaseReport.capstdoutc                 C   ra   )zbReturn captured text from stderr, if capturing is enabled.

        .. versionadded:: 3.0
        rm   c                 s   rc   rF   r4   rd   r4   r4   r5   rf      rg   z'BaseReport.capstderr.<locals>.<genexpr>zCaptured stderrrh   rj   r4   r4   r5   	capstderr   rl   zBaseReport.capstderrc                 C   
   | j dkS )zWhether the outcome is passed.r@   rC   rj   r4   r4   r5   r@         
zBaseReport.passedc                 C   rp   )zWhether the outcome is failed.rA   rq   rj   r4   r4   r5   rA      rr   zBaseReport.failedc                 C   rp   )zWhether the outcome is skipped.rB   rq   rj   r4   r4   r5   rB      rr   zBaseReport.skippedc                 C   s   | j dd S )z3The path portion of the reported node, as a string.z::r   )r>   splitrj   r4   r4   r5   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.
        Tr4   rj   r4   r4   r5   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;   )rI   rt   linenodomainr4   r4   r5   	head_line   s   
zBaseReport.head_lineconfigc                 C   s   |j j| |d\}}}|S )N)reportry   )hookpytest_report_teststatus)rI   ry   	_category_shortverboser4   r4   r5   _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_jsonrj   r4   r4   r5   _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.
        Nr4   )_report_kwargs_from_json)r   r   kwargsr4   r4   r5   
_from_json   s   
zBaseReport._from_json)+__name__
__module____qualname__r   rQ   __annotations__r   intr   r   BaseExceptionr    r
   r   r   rJ   r   rL   r!   rN   r	   rY   propertyr`   rk   rn   ro   boolr@   rA   rB   rt   ru   rx   r"   r   r   r   classmethodr   r7   objectr   r4   r4   r4   r5   r8   <   sL   
 			
(	type_namereport_classrE   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   RuntimeErrorr[   )r   r   r   urlr   r4   r4   r5   _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.
    Fwasxfailr4   r   Nr>   r;   keywordsrC   r?   r<   r:   )setupcallteardownr=   durationstartstopuser_propertiesrE   c                 K   s^   || _ || _|| _|| _|| _|| _t|pg | _t|| _|| _	|	| _
|
| _| j| d S rF   )r>   r;   r   rC   r<   r:   listr   r=   r   r   r   rG   rH   )rI   r>   r;   r   rC   r<   r:   r=   r   r   r   r   extrar4   r4   r5   rJ     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>   r:   rC   rj   r4   r4   r5   __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 )   r4   re   xr4   r4   r5   
<dictcomp>M  s    z1TestReport.from_item_and_call.<locals>.<dictcomp>r@   NrA   rB   z=There should always be a traceback entry for skipping a test.   r   r   tbstyleauto)stylez	Captured r   )r   )r:   r   r   r   r   excinfo
isinstancer   valuer%   	Exception_getreprcrash_use_item_location
reportinfoosrt   messagerQ   pathrv   repr_failure_repr_failure_pyry   	getoption_report_sectionsappendr>   r;   r   )r   r   r   r:   r   r   r   r   r   r=   rC   r<   rr   rP   rwhenrK   rX   r4   r4   r5   from_item_and_call@  s^   


zTestReport.from_item_and_call)r4   r   r   r   N)r   r   r   __doc____test__rQ   r   r   r   r   r   r   r   r   r   r   r    r   floatr   rJ   r   r   r$   r   r4   r4   r4   r5   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   r4   r>   rC   z&Literal['passed', 'failed', 'skipped']r<   Nresultr=   rE   c                 K   s6   || _ || _|| _|pg | _t|| _| j| d S rF   )r>   rC   r<   r   r   r=   rG   rH   )rI   r>   rC   r<   r   r=   r   r4   r4   r5   rJ     s   

zCollectReport.__init__c                 C   s   | j d | j fS rF   )rt   rj   r4   r4   r5   r;     s   zCollectReport.locationc                 C   s"   d| j dt| j d| jdS )Nz<CollectReport z lenresult=r   r   )r>   lenr   rC   rj   r4   r4   r5   r     s   "zCollectReport.__repr__)r4   )r   r   r   r   r:   rQ   r   r   r   r   r   r    r   r
   r$   r#   r   rJ   r   r;   r   r4   r4   r4   r5   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msgrE   Nc                 C   s
   || _ d S rF   )r<   )rI   r   r4   r4   r5   rJ     s   
zCollectErrorRepr.__init__rM   c                 C   s   |j | jdd d S )NT)red)rP   r<   )rI   rM   r4   r4   r5   rN     s   zCollectErrorRepr.toterminal)r   r   r   rQ   rJ   r!   rN   r4   r4   r4   r5   r     s    r   rz   c                 C   s*   t | ttfr|  }| jj|d< |S d S )N$report_type)r   r   r   r   r   r   )rz   datar4   r4   r5   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   r4   r4   r5   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).
    entryrE   c                 S   sH   t | }| D ]\}}t|drt |||< q	t| j|d}|S )NrG   )typer   )dataclassesasdictitemsrO   r   r   )r   r   rK   r   
entry_datar4   r4   r5   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 r4   r4   r   r   r4   r5   
<listcomp>      zE_report_to_json.<locals>.serialize_repr_traceback.<locals>.<listcomp>reprentries)r   r   r   )r   r   r   r4   r5   serialize_repr_traceback  s
   


z1_report_to_json.<locals>.serialize_repr_traceback	reprcrashc                 S   s   | d ur	t | S d S rF   )r   r   )r   r4   r4   r5   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)
r<   r   r   r   r   r=   r   r   r   r   )r   r<   r   repr_traceback
repr_crashdescription)r   r   r4   r5   serialize_exception_longrepr  s$   
	z5_report_to_json.<locals>.serialize_exception_longreprrN   r<   r   N)r   r   r   r   rQ   r   r   r   r   r8   rG   copyrO   r<   r   r   PathLikert   )rz   r   r1   rW   r4   )r   r   r   r5   r     s6   




 

r   r   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   r4   )r   r   r   r   r   r   r   )r   r   
entry_typer   r   r   	reprentry)r   r4   r5   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   r4   r4   r   r   r4   r5   r   A  r   zP_report_kwargs_from_json.<locals>.deserialize_repr_traceback.<locals>.<listcomp>r   r4   r   )repr_traceback_dictr   r4   r5   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 )Nr4   r   )r   r4   r4   r5   deserialize_repr_crashF  s   z8_report_kwargs_from_json.<locals>.deserialize_repr_crashr<   r   r   r   )r   r   r=   )r   r   rQ   r   r   r   r   
addsection)r   r   r   r   r   r   repr_traceback_datarepr_crash_datar   exception_infosectionr4   )r   r   r5   r     sD   
	r   )9r   ior   r   r   typingr   r   r   r   r   r	   r
   r   r   r   r   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%   _pytest.runnerr&   r6   r7   r8   rQ   r   r   r   r   r   r   r   r   r4   r4   r4   r5   <module>   s    +
 1



&I