o
    #if                     @   s  d Z ddlZddlmZ ddl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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 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-Z"ddl.m/Z/ ddl0m1Z1 ddl0m2Z2 dd l0m3Z3 dd!l0m4Z4 dd"l5m6Z6 dd#l7m8Z8 dd$l7m9Z9 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*lAmBZB d+ZCd,ZDd-ZEG d.d/ d/ejFZGG d0d1 d1eZHd2e6d3dfd4d5ZId6e2d3dfd7d8ZJd6e2d3eKfd9d:ZLe4d;d<d=e>d3eeKeKeKf fd>d?ZMejNG d@dA dAZOeG dBdC dCZPdDe*d6e2dEe>fdFdGZQdHeKdIeKdJeRd3eeK fdKdLZSd6e2dEe>dDe*dMeeKeTf d3eKf
dNdOZUdPe
dQee? d3eeeReKeeR eKf  fdRdSZVdTdTdUdVdWZWdUZXdXeRdYeKd3eeReKf fdZd[ZYd3eeK fd\d]ZZd^e[d3eKfd_d`Z\d=e@d3eKfdadbZ]dS )czsTerminal reporting of the full testing process.

This is a good source for looking at the various reporting hooks.
    N)Counter)partial)Path)Any)Callable)ClassVar)Dict)final)	Generator)List)Literal)Mapping)
NamedTuple)Optional)Sequence)Set)TextIO)Tuple)TYPE_CHECKING)Union)nodes)timing)ExceptionInfo)ExceptionRepr)TerminalWriter)wcswidth)running_on_ci)_PluggyPlugin)Config)ExitCode)hookimpl)Parser)Item)Node)absolutepath)bestrelpath)
BaseReport)CollectReport)
TestReport)Sessiong      ?)failedpassedskipped
deselectedxfailedxpassedwarningserrorfEc                       s   e Zd ZdZ			ddee dedededee d	df fd
dZ		dde
jde
jdeeee df dee d	df
ddZ  ZS )MoreQuietActionzA modified copy of the argparse count action which counts down and updates
    the legacy quiet attribute at the same time.

    Used to unify verbosity handling.
    NFoption_stringsdestdefaultrequiredhelpreturnc                    s   t  j||d|||d d S )Nr   )r4   r5   nargsr6   r7   r8   )super__init__)selfr4   r5   r6   r7   r8   	__class__ I/var/www/html/corbot_env/lib/python3.10/site-packages/_pytest/terminal.pyr<   W   s   
zMoreQuietAction.__init__parser	namespacevaluesoption_stringc                 C   s6   t || jdd }t|| j| t |ddd |_d S )Nr      quiet)getattrr5   setattrrG   )r=   rB   rC   rD   rE   	new_countr@   r@   rA   __call__h   s   zMoreQuietAction.__call__)NFNN)__name__
__module____qualname____doc__r   strobjectboolr   r<   argparseArgumentParser	Namespacer   rK   __classcell__r@   r@   r>   rA   r3   P   s<    
r3   c                   @   sB   e Zd ZU dZeed< eed< eeeeeee	f f f ed< dS )TestShortLogReportuG  Used to store the test status result category, shortletter and verbose word.
    For example ``"rerun", "R", ("RERUN", {"yellow": True})``.

    :ivar category:
        The class of result, for example ``“passed”``, ``“skipped”``, ``“error”``, or the empty string.

    :ivar letter:
        The short letter shown as testing progresses, for example ``"."``, ``"s"``, ``"E"``, or the empty string.

    :ivar word:
        Verbose word is shown as testing progresses in verbose mode, for example ``"PASSED"``, ``"SKIPPED"``,
        ``"ERROR"``, or the empty string.
    categoryletterwordN)
rM   rN   rO   rP   rQ   __annotations__r   r   r   rS   r@   r@   r@   rA   rX   u   s
   
 $rX   rB   r9   c              	   C   sn  | j dddd}|jddddd	d
d |jdddddd |jdddddd |jddtdd	dd |jdd	tddd |jdddtddd |jd d!dd"dd#d$ |jd%d&dd'dd(d) |jd*d+d'd,d- |jd.d/dd0d1g d2d3d4 |jd5dd6g d7d8d9d: |jd;d<ddd=d> |jd?d@dd@d1g dAdBd4 |jdCdDdDdEgdFdG | jdHdIdJdK tj| tjdLdM d S )NNzterminal reporting	Reportinggeneral)afterz-vz	--verbosecountr   verbosezIncrease verbosity)actionr6   r5   r8   z--no-header
store_trueF	no_headerzDisable headerz--no-summary
no_summaryzDisable summaryz-qz--quietzDecrease verbosityz--verbosityzSet verbosity. Default: 0.)r5   typer6   r8   z-rstorereportcharscharsa  Show extra test summary info as specified by chars: (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. (w)arnings are enabled by default (see --disable-warnings), 'N' can be used to reset the list. (default: 'fE').)rb   r5   r6   metavarr8   z--disable-warningsz--disable-pytest-warningsdisable_warningszDisable warnings summary)r6   r5   rb   r8   z-lz--showlocals
showlocalsz/Show locals in tracebacks (disabled by default))rb   r5   r6   r8   z--no-showlocalsstore_falsezFHide locals in tracebacks (negate --showlocals passed through addopts))rb   r5   r8   z--tbstyletbstyleauto)rp   longshortnolinenativez5Traceback print mode (auto/long/short/line/native/no))rj   rb   r5   r6   choicesr8   z--show-captureshowcapture)rs   stdoutstderrlogallr{   zOControls how captured stdout/stderr/log is shown on failed tests. Default: all.)rb   r5   rv   r6   r8   z--fulltracez--full-tracez,Don't cut any tracebacks (default is to cut))rb   r6   r8   z--colorcolor)yesrs   rp   z#Color terminal output (yes/no/auto)z--code-highlightr}   rs   zSWhether code should be highlighted (only if --color is also enabled). Default: yes.)r6   rv   r8   console_output_stylezConsole output: "classic", or with additional progress information ("progress" (percentage) | "count" | "progress-even-when-capture-no" (forces progress even when capture=no)progress)r8   r6   zSpecify a verbosity level for test case execution, overriding the main level. Higher levels will provide more detailed information about each test case executed.)r8   )	getgroup
_addoptionr3   int_REPORTCHARS_DEFAULTaddinir   _add_verbosity_iniVERBOSITY_TEST_CASES)rB   groupr@   r@   rA   pytest_addoption   s   			
r   configc                    sN   t | tj | j d | jjs| jjr% fdd}| jj	
d| d S d S )Nterminalreporterc                    s"   d tt|} d|  d S )N z[traceconfig] )joinmaprQ   
write_line)tagsargsmsgreporterr@   rA   mywriter  s   z"pytest_configure.<locals>.mywriterzpytest:config)TerminalReportersysrx   pluginmanagerregisteroptiondebugtraceconfigtracerootsetprocessor)r   r   r@   r   rA   pytest_configure  s   r   c                 C   s   | j j}ddh}d}|D ]'}||v r| }|dkrd}q|dkr$d}q|dkr+d}q||vr3||7 }q| j jsBd	|vrBd	| }|S | j jrPd	|v rP|d	d}|S )
NFS asxXEfAPpsxXEfNw)r   rh   lowerrk   replace)r   rh   old_aliases
reportoptscharr@   r@   rA   getreportopt  s*   r   Ttrylastreportc                 C   sH   d}| j rd}n| jrd}| j}| jdv r|dkrd}d}||| fS )Nr   .s)collectsetupteardownr*   r1   E)r+   r,   outcomewhenupper)r   rZ   r   r@   r@   rA   pytest_report_teststatus2  s   r   c                   @   sd   e Zd ZU dZeed< dZee ed< dZee	ee
f  ed< dZeed< ded	ee fd
dZdS )WarningReportao  Simple structure to hold warnings information captured by ``pytest_warning_recorded``.

    :ivar str message:
        User friendly message about the warning.
    :ivar str|None nodeid:
        nodeid that generated the warning (see ``get_location``).
    :ivar tuple fslocation:
        File system location of the source of the warning (see ``get_location``).
    messageNnodeid
fslocationTcount_towards_summaryr   r9   c                 C   s@   | j r| j S | jr| j\}}t|jjt|}| d| S dS )zSReturn the more user-friendly information about the location of a warning, or None.:N)r   r   r%   invocation_paramsdirr$   )r=   r   filenamelinenumrelpathr@   r@   rA   get_locationT  s   
zWarningReport.get_location)rM   rN   rO   rP   rQ   r\   r   r   r   r   r   r   r   r   r   r@   r@   r@   rA   r   B  s   
 
r   c                   @   s  e Zd Zddedee ddfddZded 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jdee ddfddZe	defddZdedefddZdededdfddZdd ed!eddfd"d#Zdd$d%Zd&d'd(d)d*ed+ed,e
d-ededdfd.d/Zd&d0d*ed+ededdfd1d2Zdd3d4Zd5eeef deddfd6d7Zd5ededdfd8d9Z		dd:ed;ee d<ee
 deddf
d=d>Zdd;ed:ed@eddfdAdBZ dCed@eddfdDdEZ!dFedGe"e# ddfdHdIZ$dJe%defdKdLZ&dMe'j(deddfdNdOZ)dPe*ddfdQdRZ+dGe"e, ddfdSdTZ-dedUe.eee
 ef ddfdVdWZ/dXe0ddfdYdZZ1e	defd[d\Z2deddfd]d^Z3defd_d`Z4ddadbZ5e	de
fdcddZ6ddedfZ7dXe8ddfdgdhZ9ddieddfdjdkZ:e;dldmddpdqZ<dre"eee"e f  ddfdsdtZ=dede>e fdudvZ?ddwdxZ@dGe"e, ddfdydzZAe;dld{dndod|ee
eBf deCd} fd~dZDe;dld{deCd} fddZEdeFeG ddfddZHdddZIdddZJdededee
 dedef
ddZKdd ZLdd ZMdefddZNdddZOdddZPdddZQdedededdfddZRdede>e0 fddZSdeddfddZTde0ddfddZUdddZVdddZW	ddededee ddfddZXdddZYdeZddfddZ[dddZ\dddZ]de.ee>e f fddZ^dedefddZ_dddZ`de.e>e.eeaeef f  ef fddZbdede>e# fddZcde.e>e.eeaeef f  ef fddZdde.e>e.eeaeef f  ef fddĄZedS )r   Nr   filer9   c                 C   s   dd l }|| _d| _d | _d | _i | _d | _d | _|jj	| _
|d u r%tj}|j||| _| jj| _d | _t|| _| jj| _| | _t | _|  | _d | _d | _d | _d S Nr   )_pytest.configr   _numcollected_session_showfspathstats_main_color_known_typesr   r   	startpathr   rx   create_terminal_writer_tw	fullwidth_screen_widthcurrentfspathr   rh   	hasmarkupisattyset_progress_nodeids_reported_determine_show_progress_info_show_progress_info_collect_report_last_write_already_displayed_warnings_keyboardinterrupt_memo)r=   r   r   _pytestr@   r@   rA   r<   a  s,   






zTerminalReporter.__init__)r   r`   Fc                 C   s`   | j dddkr| j ddkrdS | j ddrdS | j d}|dv r(dS |d	kr.d	S dS )
zRReturn whether we should display progress information based on the current config.capturers   r~   progress-even-when-capture-noF	setupshow>   r   r   r   r`   )r   	getoptiongetini)r=   cfgr@   r@   rA   r   {  s   
z.TerminalReporter._determine_show_progress_infoc                 C   s   | j jj}|S rL   )r   r   ra   )r=   	verbosityr@   r@   rA   r     s   
zTerminalReporter.verbosityc                 C   s
   | j dkS r   )r   r=   r@   r@   rA   
showheader     
zTerminalReporter.showheaderc                 C      t | jjjS rL   )rS   r   r   rd   r   r@   r@   rA   rd        zTerminalReporter.no_headerc                 C   r   rL   )rS   r   r   re   r   r@   r@   rA   re     r   zTerminalReporter.no_summaryc                 C   s"   | j d u r| jtjdkS | j S r   )r   r   get_verbosityr   r   r   r@   r@   rA   
showfspath  s   
zTerminalReporter.showfspathvaluec                 C   s
   || _ d S rL   )r   )r=   r   r@   r@   rA   r     r   c                 C   s   | j tjdkS r   )r   r   r   r   r   r@   r@   rA   showlongtestinfo  s   z!TerminalReporter.showlongtestinfor   c                 C   s   ddd ||}|| jv S )Nxr   )r.   r,   )getrh   )r=   r   r@   r@   rA   hasopt  s   
zTerminalReporter.hasoptr   markupc                 K   s   | j j|dd  }| jd u s|| jkr7| jd ur!| jr!|   || _t| j|}| j	  | j
|d  | jj
|fddi| d S )N::r   r   flushT)r   rootpathsplitr   r   )_write_progress_information_filling_spacer%   r   r   rt   write)r=   r   resr   fspath	relfspathr@   r@   rA   write_fspath_result  s   
z$TerminalReporter.write_fspath_resultr   prefixextrac                 K   sL   | j |kr| j  || _ | j| |r$| jj|fi | d| _ d S d S )N)r   r   rt   r   )r=   r   r   kwargsr@   r@   rA   write_ensure_prefix  s   


z$TerminalReporter.write_ensure_prefixc                 C   s   | j r| j  d | _ d S d S rL   )r   r   rt   r   r@   r@   rA   ensure_newline  s   

zTerminalReporter.ensure_newlineF   
)r   marginline_sepcontentr   r  r  c                K   sV   | j j}|tjd| | | j| ddd}||d }| j j|fd|i| dS )z+Wrap message with margin for progress info.r   TF)widthdrop_whitespacereplace_whitespaceNr   )r   width_of_current_liner   textwrapwrapr   r   )r=   r	  r   r  r  r   r  wrappedr@   r@   rA   
wrap_write  s   

zTerminalReporter.wrap_write)r   c                K   s   | j j|fd|i| d S )Nr   )r   r   )r=   r	  r   r   r@   r@   rA   r     s   zTerminalReporter.writec                 C   s   | j   d S rL   )r   r   r   r@   r@   rA   r     s   zTerminalReporter.flushrt   c                 K   s6   t |tst|dd}|   | jj|fi | d S )Nr   )errors)
isinstancerQ   r  r   rt   )r=   rt   r   r@   r@   rA   r     s   
zTerminalReporter.write_linec                 K   sZ   | dd}|r| jjt| d }d| }nd}t|}| jjd| | fi | dS )a-  Rewinds the terminal cursor to the beginning and writes the given line.

        :param erase:
            If True, will also add spaces until the full terminal width to ensure
            previous lines are properly erased.

        The rest of the keyword arguments are markup instructions.
        eraseFrF   r   r   N)popr   r   lenrQ   r   )r=   rt   r   r  
fill_countfillr@   r@   rA   rewrite  s   	
 zTerminalReporter.rewriteseptitler   c                 K   s$   |    | jj|||fi | d S rL   )r  r   r  )r=   r  r  r   r   r@   r@   rA   	write_sep   s   zTerminalReporter.write_sep=kwc                 K   s   | j j||fi | d S rL   )r   r  )r=   r  r  r  r@   r@   rA   section
  s   zTerminalReporter.sectionr   c                 K   s   | j j|fi | d S rL   )r   rt   )r=   r   r  r@   r@   rA   rt        zTerminalReporter.linerY   itemsc                 C   s2   || j v}| j |g | |r|   d S d S rL   )r   
setdefaultextend_set_main_color)r=   rY   r"  set_main_colorr@   r@   rA   
_add_stats  s
   
zTerminalReporter._add_statsexcreprc                 C   s&   t |dD ]	}| d|  qdS )Nr  zINTERNALERROR> T)rQ   r   r   )r=   r(  rt   r@   r@   rA   pytest_internalerror  s   z%TerminalReporter.pytest_internalerrorwarning_messagec                 C   s@   ddl m} |j|jf}||}t|||d}| d|g d S )Nr   )warning_record_to_str)r   r   r   r0   )_pytest.warningsr+  r   linenor   r'  )r=   r*  r   r+  r   r   warning_reportr@   r@   rA   pytest_warning_recorded  s   z(TerminalReporter.pytest_warning_recordedpluginc                 C   s&   | j jjrd| }| | d S d S )NzPLUGIN registered: )r   r   r   r   )r=   r0  r   r@   r@   rA   pytest_plugin_registered*  s   

z)TerminalReporter.pytest_plugin_registeredc                 C   s   |  d| d S )Nr-   )r'  )r=   r"  r@   r@   rA   pytest_deselected2     z"TerminalReporter.pytest_deselectedlocationc                 C   sR   | j r| j|g|R  }| |d |   d S | jr'| |d |   d S d S )Nr   )r   _locationliner  r   r   r   )r=   r   r4  rt   r@   r@   rA   pytest_runtest_logstart5  s   z(TerminalReporter.pytest_runtest_logstartr   c                 C   s<  d| _ |}t| jjj|| jd }|j|j|j}}}t|t	s$d }n|\}}| 
||g |s5|s5d S t|d}|d u rit|d}	|jrM|	sMddi}n|jrW|	rWddi}n|jr_ddi}n
|jrgddi}ni }| jtjdkr}| jj|fi | n| j|j | j|jg|jR  }
|s| j|
|fi | |jst|drt|}| jtjd	k r| jj| jj td
 d }td||}nd| d}|r|d ur| | | j r| !  n:| "  | jd|j#j$j%  | j r| jj| & d dd n| jd | jj|fi | | jd|
  d| _'| (  d S )NT)r   r   nodewasxfailgreenyellowredr       [100%]rF   z ({})z ()z[%s]r   )cyanr  ))
_tests_ranrX   r   hookr   rY   rZ   r[   r  tupler'  hasattrr+   r*   r,   r   r   r   r   r   r   addr   r5  r4  r  _get_raw_skip_reasonr   r  r  _format_trimmedr  r   r   r  r7  gatewayid!_get_progress_information_messager   r   )r=   r   repr   rY   rZ   r[   r   running_xdist	was_xfailrt   reasonavailable_widthformatted_reasonr@   r@   rA   pytest_runtest_logreportB  sv   









z)TerminalReporter.pytest_runtest_logreportc                 C   s    | j d usJ t| j| j jkS rL   )r   r  r   testscollectedr   r@   r@   rA   _is_last_item  s   zTerminalReporter._is_last_itemc           	      C   s   | j sJ | jtjdkra| jrc| jdkr&| j j}td| d| d}ntd}| j	| | j
r9|   d S |  \}}| j}|| d | jk}|re|  }| jj|d fi |d	i d S d S d S d S )
Nr   r`    [/]r=  rF   r  T)r   r   r   r   r   r   rQ  r  r   rD  rR  r   _get_main_color_width_of_current_liner   rI  r   r   )	r=   r   	num_testsprogress_length
main_color_r   	past_edger   r@   r@   rA   pytest_runtest_logfinish  s&   

 z)TerminalReporter.pytest_runtest_logfinishc                 C   s   | j sJ | j j}| jdkr4|r+| j}dtt| d}d| d}|t||S d| d| dS |rDdt| jd	 | d
dS dS )Nr`   z{:zd}rS  z/{}]z [ z / z ]d   3dz%]r=  )r   rQ  r   r   r  rQ   format)r=   	collectedr   counter_formatformat_stringr@   r@   rA   rI    s   

z2TerminalReporter._get_progress_information_messagec                 C   sN   |   \}}|  }| j}| jj| d }| j||fddi|di d S )NrF   r   T)rV  rI  rW  r   r   r   rjust)r=   r|   r[  r   r   r  r@   r@   rA   r     s
   $z:TerminalReporter._write_progress_information_filling_spacec                 C   s   | j jS )z%Return the width of the current line.)r   r  r   r@   r@   rA   rW    s   z'TerminalReporter._width_of_current_linec                 C   s\   | j r| jjjdkr| jdddd t | _d S d S | jjjdkr,| jdddd d S d S )Nr   zcollecting ... T)r   boldrF   )r   r   r   ra   r   r   timer   r   r@   r@   rA   pytest_collection  s   z"TerminalReporter.pytest_collectionc                 C   sb   |j r| d|g n
|jr| d|g dd |jD }|  jt|7  _| jr/|   d S d S )Nr1   r,   c                 S   s   g | ]	}t |tr|qS r@   )r  r"   .0r   r@   r@   rA   
<listcomp>      z9TerminalReporter.pytest_collectreport.<locals>.<listcomp>)r*   r'  r,   resultr   r  r   report_collect)r=   r   r"  r@   r@   rA   pytest_collectreport  s   z%TerminalReporter.pytest_collectreportr	   c                 C   s@  | j jjdk r	d S |s t }| jd ur| j|t krd S || _t| j	dg }t| j	dg }t| j	dg }| j
| }|rDdnd}|t| j
d | j
dkrTd	nd
 7 }|rh|d||dkrcd
nd	f 7 }|rp|d| 7 }|rx|d| 7 }| j
|kr|d| 7 }| jr| j|ddd |r| d d S d S | | d S )Nr   r1   r,   r-   z
collected zcollecting z itemrF   r   r   z / %d error%sz / %d deselectedz / %d skippedz / %d selectedT)re  r  r  )r   r   ra   r   rf  r   REPORT_COLLECTING_RESOLUTIONr  r   r   r   rQ   r   r  r   r   )r=   r	   tr  r,   r-   selectedrt   r@   r@   rA   rm    s<   


zTerminalReporter.report_collectTr   sessionr)   c                 C   s  || _ t | _| jsd S | jdddd t }| jsdt	j d| }t
t	dd }|rFdtt|d d	 }|d
| d|d	  d7 }|dtjj dtj 7 }| jdkse| jjjset
| jjdd rn|dtt	j 7 }| | | jjj| j| jd}| | d S d S )Nr  ztest session startsTre  z	platform z -- Python pypy_version_infor      z[pypy--rU  z	, pytest-z	, pluggy-r   pastebinz -- )r   
start_path)r   r   rf  _sessionstarttimer   r  platformpython_versionrd   r   rH   r   r   rQ   r   _versionversionpluggy__version__r   r   r   r   
executabler   rA  pytest_report_headerr   _write_report_lines_from_hooks)r=   rr  verinfor   rt  linesr@   r@   rA   pytest_sessionstart  s2   


z$TerminalReporter.pytest_sessionstartr  c                 C   s<   t |D ]}t|tr| | q|D ]}| | qqd S rL   )reversedr  rQ   r   )r=   r  line_or_linesrt   r@   r@   rA   r    s   
z/TerminalReporter._write_report_lines_from_hooksc                 C   s   d|j  g}|jr|dt|j |j  |jtjjkr-|d}|d	d
| |j }|r@|dd
t|  |S )Nz	rootdir: zconfigfile: 	testpathsztestpaths: {}, zplugins: %s)r   inipathappendr%   args_sourcer   
ArgsSource	TESTPATHSr   r`  r   r   list_plugin_distinfo_plugin_nameversions)r=   r   rl  r  
plugininfor@   r@   rA   r    s   

z%TerminalReporter.pytest_report_headerc                 C   s   |  d | jjj| j| j|jd}| | | jdrM|jr3| jjj	dkr-| j
d | |j | jd}|rO| j
dd |D ]}|| j
 qDd S d S d S )	NT)r   rx  r"  collectonlyr   r*   !zcollection failures)rm  r   rA  pytest_report_collectionfinishr   r"  r  r   r   ra   r   rt   _printcollecteditemsr   r   r  
toterminal)r=   rr  r  r*   rJ  r@   r@   rA   pytest_collection_finish+  s(   

z)TerminalReporter.pytest_collection_finishc              	   C   sZ  | j tj}|dk r=|dk r/tdd |D }t| D ]\}}| jd||f  qd S |D ]	}| j|j	 q1d S g }d}|D ]g}|
 dd  }	|r`||	d t| krZn|  |sO|	t|d  D ]A}
||
 t|d d }| j| |
  |dkrt|
d	d }|rt|nd }|r| D ]}| jd
|d | qqhqCd S )Nr   r  c                 s   s"    | ]}|j d dd V  qdS r   rF   r   N)r   r   )ri  itemr@   r@   rA   	<genexpr>E  s     z8TerminalReporter._printcollecteditems.<locals>.<genexpr>z%s: %dr   rF     objz{}{})r   r   r   r   r   sortedr"  r   rt   r   	listchainr  r  r  rH   inspectgetdoc
splitlinesr`  )r=   r"  test_cases_verbositycountsnamer`   r  stackindentneeded_collectorscolr  docrt   r@   r@   rA   r  A  s@   
z%TerminalReporter._printcollecteditems)wrapper
exitstatus)NNNc                 c   s    d V }| j d tjtjtjtjtjf}||v r(| js(| j	j
j| || j	d |jr6| jdt|jdd |tjkrC|   d | _n|jrQ| jdt|jdd |   |S )Nr   )r   r  r   r  T)r;  )r   rt   r   OKTESTS_FAILEDINTERRUPTEDUSAGE_ERRORNO_TESTS_COLLECTEDre   r   rA  pytest_terminal_summary
shouldfailr  rQ   _report_keyboardinterruptr   
shouldstopsummary_stats)r=   rr  r  rl  summary_exit_codesr@   r@   rA   pytest_sessionfinish_  s,   
z%TerminalReporter.pytest_sessionfinishc                 c   s^    |    |   |   |   |   |   zd V W |   |   S |   |   w rL   )summary_errorssummary_failuressummary_xfailuressummary_warningssummary_passessummary_xpassesshort_test_summaryr   r@   r@   rA   r  z  s   

z(TerminalReporter.pytest_terminal_summaryexcinfoc                 C   s   |j dd| _d S )NT)funcargs)getreprr   )r=   r  r@   r@   rA   pytest_keyboard_interrupt     z*TerminalReporter.pytest_keyboard_interruptc                 C   s   | j d ur|   d S d S rL   )r   r  r   r@   r@   rA   pytest_unconfigure  s   
z#TerminalReporter.pytest_unconfigurec                 C   s|   | j }|d us	J |jd usJ |jj}| d| d|v r<| jjjr+|| j d S |j| j | jj	ddd d S d S )Nr  KeyboardInterruptz@(to show a full traceback on KeyboardInterrupt use --full-trace)T)r:  )
r   	reprcrashr   r  r   r   	fulltracer  r   rt   )r=   r(  r   r@   r@   rA   r    s   

z*TerminalReporter._report_keyboardinterruptr   r-  domainc                    sv   dt dt f fdd}|r5||}jdkr1|dd |dtjkr1|d	tjt| 7 }|d S d
}|d S )Nr   r9   c                    s\   j | } r,| r,|d t   } d}|d dd|d< |d|7 }|S )N[r   r   r   )r   cwd_relative_nodeidendswithr  r   r   r   )r   rt   rD   r  r=   r@   rA   mkrel  s   
z-TerminalReporter._locationline.<locals>.mkrelr<  r   r   \z <- z
[location]r   )	rQ   r   r   r   r   SEPr%   r   r   )r=   r   r   r-  r  r  r   r@   r  rA   r5    s   
zTerminalReporter._locationlinec                 C   s   |j }|r|S dS )Nztest session)	head_line)r=   rJ  r  r@   r@   rA   _getfailureheadline  s   z$TerminalReporter._getfailureheadlinec                 C   sN   zt |jjW S  ty&   zt |jd d W  Y S  ty%   Y Y dS w w )N2   r   )rQ   longreprr  AttributeError)r=   rJ  r@   r@   rA   _getcrashline  s   zTerminalReporter._getcrashliner  c                 C   s   dd | j |dD S )Nc                 S   s   g | ]	}t |d s|qS )	_pdbshown)rC  rh  r@   r@   rA   rj    rk  z/TerminalReporter.getreports.<locals>.<listcomp>r@   r   r   )r=   r  r@   r@   rA   
getreports  r!  zTerminalReporter.getreportsc                    s.    dr jd}|sd S  jd u}|r| jd  }n|}t| _|s)d S i }|D ]}||jg | q-dtt	 dt
f fdd}|rKdnd} jd	|d
dd | D ]2\}}	||	}
|
r} j|
 | }ddd |D }| }n| } j|  j  qZ jd d S d S )Nr   r0   reportsr9   c                    sn   g }| D ]}|  j}|r|| qt|dk r"dtt|S tdd |D }ddd | D S )N
   r  c                 s   s$    | ]}t |d dd V  qdS r  )rQ   r   )ri  locr@   r@   rA   r    s    
zWTerminalReporter.summary_warnings.<locals>.collapsed_location_report.<locals>.<genexpr>c                 s   s.    | ]\}}d  |||dkrdndV  qdS )z{}: {} warning{}rF   r   r   N)r`  )ri  kvr@   r@   rA   r    s
    
)	r   r   r  r  r   r   rQ   r   r"  )r  	locationsr   r4  counts_by_filenamer   r@   rA   collapsed_location_report  s   

zDTerminalReporter.summary_warnings.<locals>.collapsed_location_reportzwarnings summary (final)zwarnings summaryr  TF)r:  re  r  c                 s   s    | ]}d | V  qdS )r  Nr@   rh  r@   r@   rA   r    s    z4TerminalReporter.summary_warnings.<locals>.<genexpr>zG-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html)r   r   r   r   r  r#  r   r  r   r   rQ   r  r"  r   rt   r  r   rstrip)r=   all_warningsr	   warning_reportsreports_grouped_by_messagewrr  r  r   message_reportsmaybe_locationr  indentedr@   r   rA   r    s>   



z!TerminalReporter.summary_warningsc                 C      |  ddd d S )Nr+   PASSESPsummary_passes_combinedr   r@   r@   rA   r    r  zTerminalReporter.summary_passesc                 C   r  )Nr/   XPASSESXr  r   r@   r@   rA   r    r  z TerminalReporter.summary_xpasseswhich_reports	sep_title
needed_optc                 C   s   | j jjdkr<| |r>| |}|sd S | d| |D ]"}|jr5| |}| jd|ddd | | | 	|j
 qd S d S d S )Nrs   r  r[  T)r9  re  )r   r   ro   r   r  r  sectionsr  _outrep_summary_handle_teardown_sectionsr   )r=   r  r  r  r  rJ  r   r@   r@   rA   r    s   



z(TerminalReporter.summary_passes_combinedc                    s   |  d} fdd|D S )Nr   c                    s$   g | ]}|j d kr|j kr|qS )r   )r   r   )ri  r   r   r@   rA   rj    s
    z:TerminalReporter._get_teardown_reports.<locals>.<listcomp>)r  )r=   r   r  r@   r  rA   _get_teardown_reports  s   

z&TerminalReporter._get_teardown_reportsc                 C   s   |  |D ]}| | qd S rL   )r  print_teardown_sections)r=   r   r   r@   r@   rA   r     s   z*TerminalReporter._handle_teardown_sectionsrJ  c                 C   sz   | j jj}|dkrd S |jD ],\}}|dkr||vrqd|v r:| jd| |dd  dkr4|d d }| j| qd S )Nrs   r{   r   rv  r  r  )r   r   rw   r  r   r  rt   r=   rJ  rw   secnamer	  r@   r@   rA   r  $  s   
z(TerminalReporter.print_teardown_sectionsc                 C   s   |  dd d S )Nr*   FAILURESsummary_failures_combinedr   r@   r@   rA   r  1  r3  z!TerminalReporter.summary_failuresc                 C   r  )Nr.   	XFAILURESr   r  r   r@   r@   rA   r  4  r  z"TerminalReporter.summary_xfailuresc                 C   s   | j jjdkrS|r| |rU| |}|sd S | d| | j jjdkr5|D ]}| |}| | q&d S |D ]}| |}| jd|ddd | 	| | 
|j q7d S d S d S )Nrs   r  rt   r[  Tr;  re  )r   r   ro   r   r  r  r  r   r  r  r  r   )r=   r  r  r  r  rJ  rt   r   r@   r@   rA   r  7  s&   




z*TerminalReporter.summary_failures_combinedc                 C   s   | j jjdkrD| d}|sd S | dd | jd D ]*}| |}|jdkr,d| }n	d|j d| }| jd	|d
d
d | | qd S d S )Nrs   r1   r  ERRORSr   zERROR collecting z	ERROR at z of r[  Tr   )	r   r   ro   r  r  r   r  r   r  )r=   r  rJ  r   r@   r@   rA   r  K  s   



zTerminalReporter.summary_errorsc                 C   s~   | | j | jjj}|dkrd S |jD ](\}}|dkr!||vr!q| jd| |dd  dkr6|d d }| j| qd S )Nrs   r{   rv  r  r  )r  r   r   r   rw   r  r  rt   r  r@   r@   rA   r  Z  s   
z TerminalReporter._outrep_summaryc                 C   sP  | j dk rd S t | j }|  \}}g }| j dk}|r!| jj}|D ]\}}| jj|fi |}	|r=|t|	t| 7 }|	|	 q#d
|}
|di}dt| }| jj|fi |}|ri|t|t| 7 }|
|7 }
|r| jjdi |}|dr|d d }|t|7 }|
|7 }
|r| jd	|
fd
|i| d S | j|
fi | d S )Nr  r   r  Tz in r   z[0mr  r   r   )r   r   rf  ry  build_summary_stats_liner   r   r   r  r  r   format_session_durationr  r  r   )r=   session_durationpartsrZ  
line_partsdisplay_sepr   textr   with_markupr   main_markupdurationduration_with_markupmarkup_for_end_sepr@   r@   rA   r  g  s:   



zTerminalReporter.summary_statsc           
   	      s    j sd S dtt dtdd f fdd}dtt dd f fdd}dtt dd f fdd	}dtt dd f fd
d}||t|dd|t|ddt|ddd}g } j D ]}||}|rb|| qU|rx jddddd |D ]	}	 |	 qpd S d S )Nr  statr9   c                   sT    j |g }|sd S  j}|D ]}t|t}t|| j|di}| | qd S )NT)r   r   r   _color_for_type_color_for_type_default _get_line_with_reprcrash_messager   r  )r  r  r*   r   rJ  r|   rt   r   r@   rA   show_simple  s   z8TerminalReporter.short_test_summary.<locals>.show_simplec                        j dg }|D ]7}| j} jj|fi td di}t j j|}| d| }|j}|r;|dt	| 7 }| 
| q	d S )Nr.   r0   Tr    - r   r   _get_verbose_wordr   r   r   r  _get_node_id_with_markupr8  rQ   r  )r  r.   rJ  verbose_wordmarkup_wordr   rt   rM  r   r@   rA   show_xfailed  s   
z9TerminalReporter.short_test_summary.<locals>.show_xfailedc                    r  )Nr/   r0   Tr   r  r  )r  r/   rJ  r  r  r   rt   rM  r   r@   rA   show_xpassed  s   
z9TerminalReporter.short_test_summary.<locals>.show_xpassedc           
   	      s    j dg }|rt j|ng }|sd S |d  j} jj|fi td di}d}|D ]/\}}}}	|		|rB|	t
|d  }	|d urS| d|||||	f  q/| d||||	f  q/d S )Nr,   r   r0   T	Skipped: z%s [%d] %s:%d: %sz%s [%d] %s: %s)r   r   _folded_skipsr   r  r   r   r   r  
startswithr  r  )
r  r,   fskipsr  r  r   numr   r-  rM  r   r@   rA   show_skipped  s(   

z9TerminalReporter.short_test_summary.<locals>.show_skippedr*   )r  r+   r1   )r   r  fr   pr   r  zshort test summary infoT)r?  re  )rh   r   rQ   r   r   r  r   )
r=   r  r  r  r#  REPORTCHAR_ACTIONSr  r   rb   rt   r@   r   rA   r    s2   


	

z#TerminalReporter.short_test_summaryc                 C   sB   | j d u s| jd u s| jr|   | j sJ | jsJ | j | jfS rL   )r   r   rR  r%  r   r@   r@   rA   rV    s
   

z TerminalReporter._get_main_colorunknown_type_seenc                 C   sX   | j }d|v sd|v rd}|S d|v sd|v s|rd}|S d|v s$| js(d}|S d}|S )	Nr*   r1   r;  r0   r/   r:  r+   r9  )r   rR  )r=   r'  r   rZ  r@   r@   rA   _determine_main_color  s   z&TerminalReporter._determine_main_colorc                 C   sP   g }| j D ]}|r|tvr||vr|| qtt| | _| t|| _d S rL   )r   KNOWN_TYPESr  listr   r(  rS   r   )r=   unknown_types
found_typer@   r@   rA   r%    s   

z TerminalReporter._set_main_colorc                 C   s   | j dr
|  S |  S )a  
        Build the parts used in the last summary stats line.

        The summary stats line is the line shown at the end, "=== 12 passed, 2 errors in Xs===".

        This function builds a list of the "parts" that make up for the text in that line, in
        the example above it would be:

            [
                ("12 passed", {"green": True}),
                ("2 errors", {"red": True}
            ]

        That last dict for each line is a "markup dictionary", used by TerminalWriter to
        color output.

        The final color of the line is also determined by this function, and is the second
        element of the returned tuple.
        r  )r   r   &_build_collect_only_summary_stats_line _build_normal_summary_stats_liner   r@   r@   rA   r    s   z)TerminalReporter.build_summary_stats_linekeyc                 C   s   | j |g }dd |D S )zRGet test/collection reports for the given status key, such as `passed` or `error`.c                 S   s   g | ]
}t |d dr|qS )r   T)rH   rh  r@   r@   rA   rj    s    z<TerminalReporter._get_reports_to_display.<locals>.<listcomp>r  )r=   r/  r  r@   r@   rA   _get_reports_to_display  s   z(TerminalReporter._get_reports_to_displayc           	      C   s~   |   \}}g }|D ]'}| |}|r1t|}t|t}|dd||ki}|dt|| |f q
|s;dtdifg}||fS )NTre  %d %szno tests ran)rV  r0  r  r  r   r  r  	pluralize)	r=   rZ  known_typesr  r/  r  r`   r|   r   r@   r@   rA   r.    s   
z1TerminalReporter._build_normal_summary_stats_linec                 C   s   t | d}t | d}| jdkrdddifg}d}n@|dkr3d}dt| jd	 }||difg}n*| j|k}|rCd}d
| d}nd}| j| }| d| j d| d}||difg}|rqtd }|dt|d |difg7 }||fS )Nr-   r1   r   zno tests collectedr:  Tr9  z%d %s collectedtestzno tests collected (z deselected)rT  z tests collected (r1  )r  r0  r   r2  r  )r=   r-   r  r  rZ  collected_outputall_tests_were_deselectedrq  r@   r@   rA   r-  .  s*   


z7TerminalReporter._build_collect_only_summary_stats_linerL   r  )r9   N)NN)r  )F)rr  r)   r9   N)frM   rN   rO   r   r   r   r<   r   r   propertyr   r   rS   r   rd   re   r   setterr   rQ   r   r   r  r  r  r   r   r   bytesr   r  r  r   rt   r   r   r'  r   r)  r0   WarningMessager/  r   r1  r"   r2  r   r6  r(   rP  rR  r]  rI  r   rW  rg  r'   rn  rm  r    r  r  r   r  r  r  r   r
   r  r  r   BaseExceptionr  r  r  r5  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&   r  r  r  rV  r(  r%  r   r  r0  r.  r-  r@   r@   r@   rA   r   _  sH   
		
 




D


%








6







%U
*	
r   twrJ  c                 C   sB   | |j}|d^}}|r| jd|dd}|d | S |S )Nr   Trs  )r  r   r   r   r   )r<  r   rJ  r   pathr  parts_markupr@   r@   rA   r  O  s   r  r`  r   rN  c                 C   s   | d}|dkr|d| }d}t| d}|t| |kr"dS |t| |krP|t|8 }|d| }|t| |krL|dd }|t| |ks>||7 }| |S )zFormat msg into format, ellipsizing it if doesn't fit in available_width.

    Returns None if even the ellipsis can't fit.
    r  r  Nz...r   )findr   r`  r  )r`  r   rN  iellipsisformat_widthr@   r@   rA   rF  Y  s   

rF  word_markupc                 C   s   | | }|j|fi |}t|| |}| d| }t|}z|jjj}	W n
 ty0   Y |S w t s:| j	j
dkr@d|	 }	n|j| }
td|	|
}	|	durS||	7 }|S )z?Get summary line for a report, trying to add reprcrash message.r   r<  r  z - {}N)r  r   r  r   r  r  r   r  r   r   ra   r   rF  )r   rJ  r<  rC  r  r[   r7  rt   
line_widthr   rN  r@   r@   rA   r  r  s$   


r  r   r,   c                 C   s   i }|D ]X}|j d usJ t|j tsJ ||j ft|j dks(J ||j f|j \}}}t| t|}t|di }|jdkrNd|v rNd|vrN|d |f}n|||f}||g 	| qg }	|
 D ]\}}
|		t|
g|R  qc|	S )Nru  keywordsr   skip
pytestmark)r  r  rB  r  r%   r   rH   r   r#  r  r"  )r   r,   deventr   r-  rM  rE  r/  rD   eventsr@   r@   rA   r    s$   

r  r;  r:  r9  )r*   r1   r0   r+   r`   nounc                 C   s6   |dvr| |fS | dd}| | dkr|d fS |fS )N)r1   r0   r4  r0   warningrF   r   )r   )r`   rK  r@   r@   rA   r2    s   r2  c                 C   sP   g }| D ]!\}}|j  d|j }|dr|dd  }||vr%|| q|S )Nrv  zpytest-   )project_namer}  r   r  )r  rD   r0  distr  r@   r@   rA   r    s   

r  secondsc                 C   s6   | dk r
| ddS t jt| d}| dd| dS )zQFormat the given seconds in a human readable manner to show in the final summary.<   z.2fr   )rP  zs (r>  )datetime	timedeltar   )rP  dtr@   r@   rA   r    s   r  c                 C   s   t | dr| j}|dr|tdd }|S | jsJ t| jts$J | j\}}}|dr9|tdd }|S |dkr?d}|S )zqGet the reason string of a skip/xfail/xpass test report.

    The string is just the part given by the user.
    r8  zreason: Nr  Skippedr   )rC  r8  r   r  r,   r  r  rB  )r   rM  r[  r@   r@   rA   rE    s   



rE  )^rP   rT   collectionsr   dataclassesrR  	functoolsr   r  pathlibr   rz  r   r  typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r0   r~  r   r   r   _pytest._coder   _pytest._code.coder   _pytest._ior   _pytest._io.wcwidthr   _pytest._version_pytest.assertion.utilr   r   r   r   r   r    _pytest.config.argparsingr!   _pytest.nodesr"   r#   _pytest.pathlibr$   r%   _pytest.reportsr&   r'   r(   _pytest.mainr)   ro  r)  r   Actionr3   rX   r   r   rQ   r   r   	dataclassr   r   r  r   rF  rS   r  r  r  r  r2  r  floatr  rE  r@   r@   r@   rA   <module>   s   %        v



 	