U
    `»{jSS  ã                   @  s:  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 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�r–d d l(m)Z) d d!l*m+Z+ d"d#„ Z,G d$d%„ d%ƒZ-d&d'd(d)œd*d+„Z.e
G d,d-„ d-e-ƒƒZ/e
G d.d/„ d/e-ƒƒZ0G d0d1„ d1eƒZ1d2d3d4œd5d6„Z2d7d8d9œd:d;„Z3d%d7d4œd<d=„Z4d7d7d>œd?d@„Z5dS )Aé    )ÚannotationsN)ÚStringIO)Úpprint)ÚAny)Úcast)Úfinal)ÚIterable)ÚIterator)ÚLiteral)ÚMapping)ÚNoReturn)ÚSequence)ÚTYPE_CHECKING)ÚExceptionChainRepr)ÚExceptionInfo)ÚExceptionRepr)Ú	ReprEntry)ÚReprEntryNative)ÚReprExceptionInfo©ÚReprFileLocation)ÚReprFuncArgs)Ú
ReprLocals©ÚReprTraceback)ÚTerminalRepr)ÚTerminalWriter)ÚConfig)Ú	Collector)ÚItem)Úfail)Úskip)ÚSelf)ÚCallInfoc              
   C  sd   z| j W S  tk
r^   | j}dj|d d d… Ž }d |d |d ||d ¡ | _ }| Y S X d S )Nz{}.{}.{}Úversion_infoé   z[{}] {} -- Python {} {}ÚidZsysplatformÚ
executable)Z_workerinfocacheÚAttributeErrorZ
workerinfoÚformat)ÚnodeÚdÚverÚs© r.   úN/var/www/html/bwave/python/venv/lib/python3.8/site-packages/_pytest/reports.pyÚgetworkerinfoline,   s       ÿ
r0   c                   @  sj  e Zd ZU ded< ded< ded< ded< d	ed
< ded< dddœdd„Zer^d	ddœdd„Zdddœdd„Zd	ddœdd„Ze	d	dœdd„ƒZ
e	d	dœd d!„ƒZe	d	dœd"d#„ƒZe	d	dœd$d%„ƒZe	d&dœd'd(„ƒZe	d&dœd)d*„ƒZe	d&dœd+d,„ƒZe	d	dœd-d.„ƒZe	d&dœd/d0„ƒZe	ddœd1d2„ƒZd3d4d5d6œd7d8„Zd9dœd:d;„Zed<d=d>œd?d@„ƒZdAS )BÚ
BaseReportz
str | NoneÚwhenú"tuple[str, int | None, str] | NoneÚlocationúONone | ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalReprÚlongreprzlist[tuple[str, str]]ÚsectionsÚstrÚnodeidú(Literal[('passed', 'failed', 'skipped')]Úoutcomer   ÚNone)ÚkwÚreturnc                 K  s   | j  |¡ d S ©N)Ú__dict__Úupdate)Úselfr=   r.   r.   r/   Ú__init__B   s    zBaseReport.__init__)Úkeyr>   c                 C  s   d S r?   r.   )rB   rD   r.   r.   r/   Ú__getattr__G   ó    zBaseReport.__getattr__r   ©Úoutr>   c                 C  sˆ   t | dƒr"t| jƒ}|r"| |¡ | j}|d kr4d S t |dƒrTtt|ƒ}| |¡ n0zt|ƒ}W n t	k
rx   d}Y nX | |¡ d S )Nr*   Ú
toterminalz<unprintable longrepr>)
Úhasattrr0   r*   Úliner6   r   r   rI   r8   ÚUnicodeEncodeError)rB   rH   Zworker_infor6   Zlongrepr_terminalr-   r.   r.   r/   rI   I   s    





zBaseReport.toterminalzIterator[tuple[str, str]])Úprefixr>   c                 c  s(   | j D ]\}}| |¡r||fV  qd S r?   )r7   Ú
startswith)rB   rM   ÚnameÚcontentr.   r.   r/   Úget_sections]   s    
zBaseReport.get_sections©r>   c                 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	hasmarkuprI   ÚgetvalueÚstrip)rB   ÚfileZtwÚexcr.   r.   r/   Úlongreprtextb   s    
zBaseReport.longreprtextc                 C  s   d  dd„ |  d¡D ƒ¡S )z_Return captured log lines, if log capturing is enabled.

        .. versionadded:: 3.5
        Ú
c                 s  s   | ]\}}|V  qd S r?   r.   ©Ú.0rM   rP   r.   r.   r/   Ú	<genexpr>v   s    z$BaseReport.caplog.<locals>.<genexpr>zCaptured log©ÚjoinrQ   ©rB   r.   r.   r/   Úcaplogp   s    
ÿzBaseReport.caplogc                 C  s   d  dd„ |  d¡D ƒ¡S )zbReturn captured text from stdout, if capturing is enabled.

        .. versionadded:: 3.0
        Ú c                 s  s   | ]\}}|V  qd S r?   r.   rY   r.   r.   r/   r[   €   s    z'BaseReport.capstdout.<locals>.<genexpr>zCaptured stdoutr\   r^   r.   r.   r/   Ú	capstdoutz   s    
ÿzBaseReport.capstdoutc                 C  s   d  dd„ |  d¡D ƒ¡S )zbReturn captured text from stderr, if capturing is enabled.

        .. versionadded:: 3.0
        r`   c                 s  s   | ]\}}|V  qd S r?   r.   rY   r.   r.   r/   r[   Š   s    z'BaseReport.capstderr.<locals>.<genexpr>zCaptured stderrr\   r^   r.   r.   r/   Ú	capstderr„   s    
ÿzBaseReport.capstderrÚboolc                 C  s
   | j dkS )zWhether the outcome is passed.Úpassed©r;   r^   r.   r.   r/   rd   Ž   s    zBaseReport.passedc                 C  s
   | j dkS )zWhether the outcome is failed.Úfailedre   r^   r.   r.   r/   rf   “   s    zBaseReport.failedc                 C  s
   | j dkS )zWhether the outcome is skipped.Úskippedre   r^   r.   r.   r/   rg   ˜   s    zBaseReport.skippedc                 C  s   | j  d¡d S )z3The path portion of the reported node, as a string.z::r   )r9   Úsplitr^   r.   r.   r/   Ú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.
        Tr.   r^   r.   r.   r/   Úcount_towards_summary¢   s    
z BaseReport.count_towards_summaryc                 C  s   | j dk	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)r4   )rB   ri   ÚlinenoÚdomainr.   r.   r/   Ú	head_line®   s    
zBaseReport.head_liner   zMapping[str, bool]ztuple[str, Mapping[str, bool]])ÚconfigÚdefault_markupr>   c                 C  sv   |j j| |d�\}}}t|tƒr(||fS t|tƒrbt|ƒdkrb|\}}t|tƒrbt|tƒrb||fS td|›d�ƒ d S )N)Úreportrn   é   zSpytest_report_teststatus() hook (from a plugin) returned an invalid verbose value: z8.
Expected either a string or a tuple of (word, markup).)ÚhookZpytest_report_teststatusÚ
isinstancer8   r   Úlenr   r    )rB   rn   ro   Z	_categoryZ_shortÚverboseÚwordÚmarkupr.   r.   r/   Ú_get_verbose_word_with_markupÃ   s     ÿ

ÿz(BaseReport._get_verbose_word_with_markupúdict[str, Any]c                 C  s   t | ƒS )zÞReturn 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_jsonr^   r.   r.   r/   Ú_to_jsonØ   s    zBaseReport._to_jsonzdict[str, object]r"   ©Ú
reportdictr>   c                 C  s   t |ƒ}| f |Ž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.
        )Ú_report_kwargs_from_json)Úclsr}   Úkwargsr.   r.   r/   Ú
_from_jsonâ   s    
zBaseReport._from_jsonN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__rC   r   rE   rI   rQ   ÚpropertyrW   r_   ra   rb   rd   rf   rg   ri   rj   rm   rx   r{   Úclassmethodr�   r.   r.   r.   r/   r1   8   sF   
			
r1   r8   ztype[BaseReport]r   )Ú	type_nameÚreport_classr>   c                 C  st   d}t ƒ }td|d� td| › �|d� td|› �|d� t||d� td|› �|d� td|d� t| ¡ ƒ‚d S )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   ÚRuntimeErrorrS   )rˆ   r‰   r}   ÚurlrŠ   r.   r.   r/   Ú_report_unserialization_failureð   s    r�   c                   @  sh   e Zd ZU dZdZded< dddd	d
dddddddddœdd„Zddœdd„Zeddd dœdd„ƒZ	dS )Ú
TestReportz�Basic test report object (also used for setup and teardown calls if
    they fail).

    Reports can contain arbitrary extra attributes.
    Fr8   Zwasxfailr.   r   Nztuple[str, int | None, str]zMapping[str, Any]r:   r5   z&Literal[('setup', 'call', 'teardown')]úIterable[tuple[str, str]]Úfloatz#Iterable[tuple[str, object]] | Noner<   )r9   r4   Úkeywordsr;   r6   r2   r7   ÚdurationÚstartÚstopÚuser_propertiesr>   c                 K  s^   || _ || _|| _|| _|| _|| _t|p,g ƒ| _t|ƒ| _|| _	|	| _
|
| _| j |¡ d S r?   )r9   r4   r‘   r;   r6   r2   Úlistr•   r7   r’   r“   r”   r@   rA   )rB   r9   r4   r‘   r;   r6   r2   r7   r’   r“   r”   r•   Úextrar.   r.   r/   rC     s    
zTestReport.__init__rR   c              	   C  s(   d| j j› d| j›d| j›d| j›d�	S )Nú<ú z when=ú	 outcome=ú>)Ú	__class__r‚   r9   r2   r;   r^   r.   r.   r/   Ú__repr__I  s    zTestReport.__repr__r   zCallInfo[None])ÚitemÚcallr>   c                 C  sf  |j }|dkst‚|j}|j}|j}dd„ |jD ƒ}|j}g }	|jsNd}
d}nÆt|tƒsbd}
|}n²t|j	t
jƒrâd}
| ¡ }|dk	sŒtdƒ‚|j	jrÌ| ¡ dd	… \}}|dk	s´t‚t |¡|d
 |jf}nt|jƒ|j|jf}n2d}
|j dkrü| |¡}n|j||j dd¡d�}|jD ]&\}}}|	 d|› d|› �|f¡ �q| |j|j||
|||	||||jd�S )z‹Create 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.   ©rZ   Úxr.   r.   r/   Ú
<dictcomp>Y  s      z1TestReport.from_item_and_call.<locals>.<dictcomp>rd   Nrf   rg   z=There should always be a traceback entry for skipping a test.rq   r¡   rŸ   ZtbstyleÚauto)Ústylez	Captured r™   )r•   )r2   ÚAssertionErrorr’   r“   r”   r‘   Úexcinfors   r   Úvaluer!   Ú	ExceptionZ_getreprcrashZ_use_item_locationZ
reportinfoÚosri   Úmessager8   Úpathrk   Zrepr_failureZ_repr_failure_pyrn   Z	getoptionZ_report_sectionsÚappendr9   r4   r•   )r   rž   rŸ   r2   r’   r“   r”   r‘   r¨   r7   r;   r6   Úrr­   rK   ZrwhenrD   rP   r.   r.   r/   Úfrom_item_and_callL  sb    ú
ÿþ
 ÿõzTestReport.from_item_and_call)r.   r   r   r   N)
r‚   rƒ   r„   Ú__doc__Z__test__r…   rC   r�   r‡   r°   r.   r.   r.   r/   rŽ   þ   s   
     ð&>rŽ   c                   @  sN   e Zd ZdZdZddddddd	d
œdd„Zeddœdd„ƒZddœdd„ZdS )ÚCollectReportzSCollection report object.

    Reports can contain arbitrary extra attributes.
    r    r.   r8   r:   r5   zlist[Item | Collector] | Noner�   r<   )r9   r;   r6   Úresultr7   r>   c                 K  s6   || _ || _|| _|pg | _t|ƒ| _| j |¡ d S r?   )r9   r;   r6   r³   r–   r7   r@   rA   )rB   r9   r;   r6   r³   r7   r—   r.   r.   r/   rC   —  s    

zCollectReport.__init__r3   rR   c                 C  s   | j d | j fS r?   )ri   r^   r.   r.   r/   r4   ¸  s    zCollectReport.locationc                 C  s"   d| j ›dt| jƒ› d| j›d�S )Nz<CollectReport z lenresult=rš   r›   )r9   rt   r³   r;   r^   r.   r.   r/   r�   ¾  s    zCollectReport.__repr__N)r.   )	r‚   rƒ   r„   r±   r2   rC   r†   r4   r�   r.   r.   r.   r/   r²   Ž  s    ö!r²   c                   @  s,   e Zd Zdddœdd„Zdddœdd	„Zd
S )ÚCollectErrorReprr8   r<   )Úmsgr>   c                 C  s
   || _ d S r?   )r6   )rB   rµ   r.   r.   r/   rC   Ã  s    zCollectErrorRepr.__init__r   rG   c                 C  s   |j | jdd� d S )NT)Úred)rK   r6   )rB   rH   r.   r.   r/   rI   Æ  s    zCollectErrorRepr.toterminalN)r‚   rƒ   r„   rC   rI   r.   r.   r.   r/   r´   Â  s   r´   zCollectReport | TestReportúdict[str, Any] | None)rp   r>   c                 C  s*   t | ttfƒr&|  ¡ }| jj|d< |S d S )Nú$report_type)rs   rŽ   r²   r{   rœ   r‚   )rp   Údatar.   r.   r/   Úpytest_report_to_serializableÊ  s
    rº   ry   z!CollectReport | TestReport | None)r¹   r>   c                 C  sN   d| krJ| d dkrt  | ¡S | d dkr4t | ¡S dsJtd | d ¡ƒ‚d S )Nr¸   rŽ   r²   Fz(Unknown report_type unserialize data: {})rŽ   r�   r²   r§   r)   )r¹   r.   r.   r/   Úpytest_report_from_serializableÕ  s    


ÿr»   c                   sâ   dddœdd„‰dddœ‡fdd	„‰d
ddœdd„‰ dddœ‡ ‡fdd„}| j  ¡ }t| jdƒr–t| jdƒr†t| jdƒr†|| ƒ|d< q t| jƒ|d< n
| j|d< |D ]8}t|| tjƒrÌt || ¡||< q¤|dkr¤d||< q¤|S )z´Return the contents of this report as a dict of builtin entries,
    suitable for serialization.

    This was originally the serialize_report() function from xdist (ca03269).
    zReprEntry | ReprEntryNativery   )Úentryr>   c                 S  sH   t  | ¡}| ¡ D ] \}}t|dƒrt  |¡||< qt| ƒj|dœ}|S )Nr@   )Útyper¹   )ÚdataclassesÚasdictÚitemsrJ   r½   r‚   )r¼   r¹   rD   r©   Ú
entry_datar.   r.   r/   Úserialize_repr_entryê  s    

z-_report_to_json.<locals>.serialize_repr_entryr   )Úreprtracebackr>   c                   s&   t  | ¡}‡ fdd„| jD ƒ|d< |S )Nc                   s   g | ]}ˆ |ƒ‘qS r.   r.   r¢   ©rÂ   r.   r/   Ú
<listcomp>ö  s    zE_report_to_json.<locals>.serialize_repr_traceback.<locals>.<listcomp>Úreprentries)r¾   r¿   rÆ   )rÃ   r³   rÄ   r.   r/   Úserialize_repr_tracebackô  s
    

ÿ
z1_report_to_json.<locals>.serialize_repr_tracebackzReprFileLocation | Noner·   )Ú	reprcrashr>   c                 S  s   | d k	rt  | ¡S d S d S r?   )r¾   r¿   )rÈ   r.   r.   r/   Úserialize_repr_crashû  s    
z-_report_to_json.<locals>.serialize_repr_crashr1   )Úrepr>   c                   s‚   | j d k	st‚tt| j ƒ}ˆ |jƒˆ|jƒ|jdœ}t|tƒrvg |d< |j	D ]&\}}}|d  
ˆ|ƒˆ |ƒ|f¡ qLnd |d< |S )N)rÈ   rÃ   r7   Úchain)r6   r§   r   r   rÈ   rÃ   r7   rs   r   rË   r®   )rÊ   r6   r³   Zrepr_tracebackZ
repr_crashÚdescription)rÉ   rÇ   r.   r/   Úserialize_exception_longrepr  s"    ý
ýÿz5_report_to_json.<locals>.serialize_exception_longreprrI   rÃ   rÈ   r6   r³   N)	r@   ÚcopyrJ   r6   r8   rs   r«   ÚPathLikeri   )rp   rÍ   r+   rO   r.   )rÉ   rÂ   rÇ   r/   rz   ã  s&    

 ÿ

rz   r|   c                   sä   ‡fdd„‰ ‡ fdd„}ddœdd„}ˆd	 ràd
ˆd	 kràdˆd	 krà|ˆd	 d ƒ}|ˆd	 d
 ƒ}ˆd	 d r°g }ˆd	 d D ]"\}}}|  ||ƒ||ƒ|f¡ q‚t|ƒ}	nt||d�}	ˆd	 d D ]}
|	j|
Ž  qÈ|	ˆd	< ˆS )z­Return **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r„d }d }d }|d r:t f |d Ž}|d rPtf |d Ž}|d rht|d d ƒ}t|d ||||d d	�}n"|d
kršt|d ƒ}nt|tˆ ƒ |S )Nr¹   r½   r   ÚreprfuncargsÚreprfilelocÚ
reprlocalsÚlinesr¦   )rÓ   rÐ   rÒ   rÑ   r¦   r   )r   r   r   r   r   r�   rŽ   )rÁ   r¹   Z
entry_typerÐ   rÑ   rÒ   Z	reprentry)r}   r.   r/   Údeserialize_repr_entry3  s.    ûz8_report_kwargs_from_json.<locals>.deserialize_repr_entryc                   s$   ‡ fdd„| d D ƒ| d< t f | ŽS )Nc                   s   g | ]}ˆ |ƒ‘qS r.   r.   r¢   ©rÔ   r.   r/   rÅ   O  s    zP_report_kwargs_from_json.<locals>.deserialize_repr_traceback.<locals>.<listcomp>rÆ   r   )Zrepr_traceback_dictrÕ   r.   r/   Údeserialize_repr_tracebackN  s    
ÿ
z<_report_kwargs_from_json.<locals>.deserialize_repr_tracebackr·   ©Zrepr_crash_dictc                 S  s   | d k	rt f | ŽS d S d S r?   r   r×   r.   r.   r/   Údeserialize_repr_crashT  s    
z8_report_kwargs_from_json.<locals>.deserialize_repr_crashr6   rÈ   rÃ   rË   )rÃ   rÈ   r7   )r®   r   r   Z
addsection)r}   rÖ   rØ   rÃ   rÈ   rË   Zrepr_traceback_dataZrepr_crash_datarÌ   Zexception_infoÚsectionr.   )rÔ   r}   r/   r~   ,  sJ    ÿ
þ
ý
ÿÿþýÿÿþr~   )6Ú
__future__r   r¾   Úior   r«   r   Útypingr   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    r!   Útyping_extensionsr"   Z_pytest.runnerr#   r0   r1   r�   rŽ   r²   r´   rº   r»   rz   r~   r.   r.   r.   r/   Ú<module>   s`    9 3I