o
    Ú­jhQ  ã                   @   s¸  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 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/ed'd(d)�Z0G d*d(„ d(ƒZ1d+e2d,ee1 d-efd.d/„Z3e#G d0d1„ d1e1ƒƒZ4e#G d2d3„ d3e1ƒƒZ5G d4d5„ d5eƒZ6d6ee5e4f d-eee2ef  fd7d8„Z7d9ee2ef d-eee5e4f  fd:d;„Z8d6e1d-ee2ef fd<d=„Z9d>ee2ef d-ee2ef fd?d@„Z:dS )Aé    N)ÚStringIO)Úpprint)ÚAny)Úcast)ÚDict)ÚIterable)ÚIterator)ÚList)ÚMapping)ÚNoReturn)ÚOptional)ÚTuple)ÚType)ÚTYPE_CHECKING)ÚTypeVar)ÚUnion)ÚExceptionChainRepr)ÚExceptionInfo)ÚExceptionRepr)Ú	ReprEntry)ÚReprEntryNative)ÚReprExceptionInfo©ÚReprFileLocation)ÚReprFuncArgs)Ú
ReprLocals©ÚReprTraceback)ÚTerminalRepr)ÚTerminalWriter)Úfinal)ÚConfig)Ú	Collector)ÚItem)Úskip)ÚLiteral)ÚCallInfoc              
   C   s\   z| j W S  ty-   | j}d|d d d…  }d |d |d ||d ¡ | _ }| Y S w )Nz%s.%s.%sÚversion_infoé   z[{}] {} -- Python {} {}ÚidÚsysplatformÚ
executable)Ú_workerinfocacheÚAttributeErrorÚ
workerinfoÚformat)ÚnodeÚdÚverÚs© r4   úL/var/www/html/CropPilot/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< ded< d	ed
dfdd„ZerPd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ú&Literal['passed', 'failed', 'skipped']ÚoutcomeÚkwÚreturnc                 K   s   | j  |¡ d S ©N)Ú__dict__Úupdate)ÚselfrA   r4   r4   r5   Ú__init__E   s   zBaseReport.__init__Úkeyc                 C   s   d S rC   r4   )rF   rH   r4   r4   r5   Ú__getattr__J   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   rK   ÚstrÚUnicodeEncodeError)rF   rJ   Úworker_infor<   Úlongrepr_terminalr3   r4   r4   r5   rK   M   s    




ÿzBaseReport.toterminalÚprefixc                 c   s*   � | j D ]\}}| |¡r||fV  qd S rC   )r=   Ú
startswith)rF   rR   ÚnameÚcontentr4   r4   r5   Úget_sectionsa   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   Ú	hasmarkuprK   ÚgetvalueÚstrip)rF   ÚfileÚtwÚexcr4   r4   r5   Úlongreprtextf   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   r4   ©Ú.0rR   rU   r4   r4   r5   Ú	<genexpr>z   ó   € 
ÿz$BaseReport.caplog.<locals>.<genexpr>zCaptured log©ÚjoinrV   ©rF   r4   r4   r5   Úcaplogt   ó   
ÿzBaseReport.caplogc                 C   r^   )zbReturn captured text from stdout, if capturing is enabled.

        .. versionadded:: 3.0
        Ú c                 s   r`   rC   r4   ra   r4   r4   r5   rc   „   rd   z'BaseReport.capstdout.<locals>.<genexpr>zCaptured stdoutre   rg   r4   r4   r5   Ú	capstdout~   ri   zBaseReport.capstdoutc                 C   r^   )zbReturn captured text from stderr, if capturing is enabled.

        .. versionadded:: 3.0
        rj   c                 s   r`   rC   r4   ra   r4   r4   r5   rc   Ž   rd   z'BaseReport.capstderr.<locals>.<genexpr>zCaptured stderrre   rg   r4   r4   r5   Ú	capstderrˆ   ri   zBaseReport.capstderrc                 C   ó
   | j dkS )zWhether the outcome is passed.Úpassed©r@   rg   r4   r4   r5   rn   ’   ó   
zBaseReport.passedc                 C   rm   )zWhether the outcome is failed.Úfailedro   rg   r4   r4   r5   rq   —   rp   zBaseReport.failedc                 C   rm   )zWhether the outcome is skipped.Úskippedro   rg   r4   r4   r5   rr   œ   rp   zBaseReport.skippedc                 C   s   | j  d¡d S )z3The path portion of the reported node, as a string.z::r   )r>   Úsplitrg   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   rg   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;   )rF   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)rF   ry   Ú	_categoryÚ_shortÚverboser4   r4   r5   Ú_get_verbose_wordÇ   s   ÿzBaseReport._get_verbose_wordc                 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_jsonrg   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   rN   Ú__annotations__r   Úintr   r   ÚBaseExceptionr   r	   r   rG   r   rI   r   rK   r   rV   Úpropertyr]   rh   rk   rl   Úboolrn   rq   rr   rt   ru   rx   r!   r€   r   r‚   Úclassmethodr   r7   Úobjectr‡   r4   r4   r4   r5   r8   ;   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   ÚRuntimeErrorrX   )r’   r“   r„   Úurlr”   r4   r4   r5   Ú_report_unserialization_failureå   s   r—   c                   @   sÐ   e Zd ZdZdZ					ddedeeee ef de	ee
f d	d
dedee eeeef eef d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 )Ú
TestReportz�Basic test report object (also used for setup and teardown calls if
    they fail).

    Reports can contain arbitrary extra attributes.
    Fr4   r   Nr>   r;   Úkeywordsr@   r?   r<   r:   z$Literal['setup', 'call', 'teardown']r=   ÚdurationÚstartÚstopÚuser_propertiesrB   c                 K   s^   || _ || _|| _|| _|| _|| _t|pg ƒ| _t|ƒ| _|| _	|	| _
|
| _| j |¡ d S rC   )r>   r;   r™   r@   r<   r:   Úlistr�   r=   rš   r›   rœ   rD   rE   )rF   r>   r;   r™   r@   r<   r:   r=   rš   r›   rœ   r�   Úextrar4   r4   r5   rG   ý   s   
zTestReport.__init__c                 C   s   d  | jj| j| j| j¡S )Nz <{} {!r} when={!r} outcome={!r}>)r/   Ú	__class__rˆ   r>   r:   r@   rg   r4   r4   r5   Ú__repr__9  s   ÿzTestReport.__repr__ÚitemÚcallz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 )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 )é   r4   ©rb   Úxr4   r4   r5   Ú
<dictcomp>K  s    z1TestReport.from_item_and_call.<locals>.<dictcomp>rn   Nrq   rr   z=There should always be a traceback entry for skipping a test.é   r¥   r£   ÚtbstyleÚauto)Ústylez	Captured ú )r�   )r:   rš   r›   rœ   r™   ÚexcinfoÚ
isinstancer   Úvaluer$   Ú	ExceptionÚ_getreprcrashÚ_use_item_locationÚ
reportinfoÚosrt   ÚmessagerN   Úpathrv   Úrepr_failureÚ_repr_failure_pyry   Ú	getoptionÚ_report_sectionsÚappendr>   r;   r�   )rƒ   r¢   r£   r:   rš   r›   rœ   r™   r®   r=   r@   r<   Úrr·   rM   ÚrwhenrH   rU   r4   r4   r5   Úfrom_item_and_call>  s^   ú

ÿ
ÿõzTestReport.from_item_and_call)r4   r   r   r   N)rˆ   r‰   rŠ   Ú__doc__Ú__test__rN   r   r   rŒ   r
   r   r   r   r�   r   r   Úfloatr‘   rG   r¡   r�   r#   r¿   r4   r4   r4   r5   r˜   ó   sL    òþý
üûÿú	÷
öõôóò
ð<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>   r@   r?   r<   NÚresultr=   rB   c                 K   s6   || _ || _|| _|pg | _t|ƒ| _| j |¡ d S rC   )r>   r@   r<   rÄ   rž   r=   rD   rE   )rF   r>   r@   r<   rÄ   r=   rŸ   r4   r4   r5   rG   ‰  s   

zCollectReport.__init__c                 C   s   | j d | j fS rC   )rt   rg   r4   r4   r5   r;   ¨  s   zCollectReport.locationc                 C   s   d  | jt| jƒ| j¡S )Nz.<CollectReport {!r} lenresult={} outcome={!r}>)r/   r>   ÚlenrÄ   r@   rg   r4   r4   r5   r¡   ®  s   ÿzCollectReport.__repr__)r4   )rˆ   r‰   rŠ   rÀ   r:   rN   r   r   r�   r   rŒ   r   r   r	   r#   r"   r   rG   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ÚmsgrB   Nc                 C   s
   || _ d S rC   )r<   )rF   rÇ   r4   r4   r5   rG   µ  s   
zCollectErrorRepr.__init__rJ   c                 C   s   |j | jdd� d S )NT)Úred)rM   r<   )rF   rJ   r4   r4   r5   rK   ¸  s   zCollectErrorRepr.toterminal)rˆ   r‰   rŠ   rN   rG   r   rK   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ƒr‚t || ¡||< qn|dkrŠd||< qn|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).
    Ú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_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 rC   )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_longreprrK   r<   rÄ   N)r   r   r   r   rN   r   r   r   r   r8   rD   ÚcopyrL   r<   r¯   rµ   ÚPathLikert   )rz   râ   r1   rT   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 )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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   rN   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…   );rÏ   rµ   Úior   r   Útypingr   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.compatr    Ú_pytest.configr!   Ú_pytest.nodesr"   r#   Ú_pytest.outcomesr$   Útyping_extensionsr%   Ú_pytest.runnerr&   r6   r7   r8   rN   r—   r˜   rÃ   rÆ   rË   rÌ   r�   r…   r4   r4   r4   r5   Ú<module>   s†     +ÿÿ
þ 3
ÿ
þ
ÿ
þ&I