o
    h                     @  s   d 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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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+Zddl,m-Z- ddl.m/Z/ ddl.m0Z0 ddl.m1Z1 ddl.m2Z2 ddl3m4Z4 ddl5m6Z6 dd l5m7Z7 dd!l8m9Z9 dd"l8m:Z: dd#l;m<Z< dd$l;m=Z= dd%l;m>Z> erdd&l?m@Z@ d'ZAd(ZBd)ZCG d*d+ d+ejDZEG d,d- d-eZFdrd2d3ZGdsd6d7ZHdtd9d:ZIe2d;d<dud@dAZJejKG dBdC dCZLeG dDdE dEZMdvdIdJZNdwdPdQZOdxdTdUZPdyd[d\ZQd]d]d^d_d`ZRd^ZSdzdddeZTd{dgdhZUd|dkdlZVd|dmdnZWd}dpdqZXdS )~zsTerminal reporting of the full testing process.

This is a good source for looking at the various reporting hooks.
    )annotationsN)Counter)Callable)	Generator)Mapping)Sequence)partial)Path)Any)ClassVar)final)Literal)
NamedTuple)TextIO)TYPE_CHECKING)compat)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                      s8   e Zd ZdZ			dd fddZ	dd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Sequence[str]deststrdefaultobjectrequiredboolhelp
str | NonereturnNonec                   s   t  j||d|||d d S )Nr   )r0   r2   nargsr4   r6   r8   )super__init__)selfr0   r2   r4   r6   r8   	__class__ Q/var/www/html/openai_agents/venv/lib/python3.10/site-packages/_pytest/terminal.pyr>   T   s   
zMoreQuietAction.__init__parserargparse.ArgumentParser	namespaceargparse.Namespacevaluesstr | Sequence[object] | Noneoption_stringc                 C  s6   t || jdd }t|| j| t |ddd |_d S )Nr      quiet)getattrr2   setattrrL   )r?   rD   rF   rH   rJ   	new_countrB   rB   rC   __call__e   s   zMoreQuietAction.__call__)NFN)r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   N)
rD   rE   rF   rG   rH   rI   rJ   r9   r:   r;   )__name__
__module____qualname____doc__r>   rP   __classcell__rB   rB   r@   rC   r/   M   s    
r/   c                   @  s*   e Zd ZU dZded< ded< d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.
    r3   categoryletterz$str | tuple[str, Mapping[str, bool]]wordN)rR   rS   rT   rU   __annotations__rB   rB   rB   rC   rW   r   s
   
 rW   rD   r   r:   r;   c              	   C  s  | 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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d0dd1d |jd2dd0d3d4 |jd5d6d$d7d8g d9d:d; |jd<dd=dd>d |jd?d$d@g dAdBdCdD |jdEdFdddGdH |jdIdJd$dJd8g dKdLd; |jdMdNdNdOgdPdQ | jdRdSdTdU tj| tj	dVdW d S )XNzterminal reporting	Reportinggeneral)afterz-vz	--verbosecountr   verbosezIncrease verbosity)actionr4   r2   r8   z--no-header
store_trueF	no_headerzDisable headerz--no-summary
no_summaryzDisable summaryz--no-fold-skippedstore_falsefold_skippedTz+Do not fold skipped tests in short summary.)ra   r2   r4   r8   z--force-short-summaryforce_short_summaryz=Force condensed summary output regardless of verbosity level.z-qz--quietzDecrease verbosityz--verbosityzSet verbosity. Default: 0.)r2   typer4   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').)ra   r2   r4   metavarr8   z--disable-warningsz--disable-pytest-warningsdisable_warningszDisable warnings summary)r4   r2   ra   r8   z-lz--showlocals
showlocalsz/Show locals in tracebacks (disabled by default)z--no-showlocalszFHide locals in tracebacks (negate --showlocals passed through addopts))ra   r2   r8   z--tbstyletbstyleauto)rq   longshortnolinenativez5Traceback print mode (auto/long/short/line/native/no))rl   ra   r2   r4   choicesr8   z
--xfail-tbxfail_tbz1Show tracebacks for xfail (as long as --tb != no)z--show-captureshowcapture)rt   stdoutstderrlogallr}   zOControls how captured stdout/stderr/log is shown on failed tests. Default: all.)ra   r2   rw   r4   r8   z--fulltracez--full-tracez,Don't cut any tracebacks (default is to cut))ra   r4   r8   z--colorcolor)yesrt   rq   z#Color terminal output (yes/no/auto)z--code-highlightr   rt   zSWhether code should be highlighted (only if --color is also enabled). Default: yes.)r4   rw   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   r4   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
_addoption	addoptionr/   int_REPORTCHARS_DEFAULTaddinir   _add_verbosity_iniVERBOSITY_TEST_CASES)rD   grouprB   rB   rC   pytest_addoption   s  			
r   configr   c                   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mapr3   
write_line)tagsargsmsgreporterrB   rC   mywriter$  s   z"pytest_configure.<locals>.mywriterzpytest:config)TerminalReportersysrz   pluginmanagerregisteroptiondebugtraceconfigtracerootsetprocessor)r   r   rB   r   rC   pytest_configure  s   r   r3   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   rj   lowerrm   replace)r   rj   old_aliases
reportoptscharrB   rB   rC   getreportopt+  s*   r   Ttrylastreportr"   tuple[str, str, str]c                 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&   r-   E)r'   r(   outcomewhenupper)r   rY   r   rB   rB   rC   pytest_report_teststatusD  s   r   c                   @  sH   e Zd ZU dZded< dZded< dZded< d	Zd
ed< d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``).
    r3   messageNr9   nodeidztuple[str, int] | None
fslocationTr   count_towards_summaryr   r   r:   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relpathrB   rB   rC   get_locationf  s   
zWarningReport.get_location)r   r   r:   r9   )	rR   rS   rT   rU   r[   r   r   r   r   rB   rB   rB   rC   r   T  s   
 
r   c                   @  s  e Zd Zdddd	ZdddZedddZedddZedddZedddZ	edddZ
e
jdddZ
edddZdd d!Zdd%d&Zddd*d+Zdd,d-Zd.d/d0d1dd6d7Zd.d8dd9d:Zdd;d<Zdd?d@ZddAdBZ		dddHdIZdddLdMZddOdPZddTdUZddXdYZdd\d]Zdd`daZddcddZddgdhZd dkdlZeddmdnZ e!dodpddrdsZ"ddtduZ#ddvdwZ$ddxdyZ%eddzd{Z&dd|d}Z'dddZ(ddddZ)e!doddddZ*dddZ+dddZ,dddZ-dddZ.e!dodpd	ddZ/e!dodpd
ddZ0dddZ1dddZ2dddZ3dddZ4dd Z5dd Z6dddZ7dddZ8dddZ9dddZ:dddZ;dddZ<dddZ=dddZ>dddÄZ?dddńZ@ddƜdddɄZAddd˄ZBddd΄ZCdddЄZDddd҄ZEdddՄZFddd؄ZGdddڄZHddd݄ZIdddZJdddZKdddZLdS (  r   Nr   r   fileTextIO | Noner:   r;   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| _| jj| _t| | _t | _t | _|  | _t ! | _"d | _#d | _$d S Nr   )%_pytest.configr   _numcollected_session_showfspathstats_main_color_known_typesr   r   	startpathr   rz   create_terminal_writer_tw	fullwidth_screen_widthcurrentfspathr   rj   r   rf   foldskipped	hasmarkupr   CallableBoolisattyset_progress_nodeids_reported_timing_nodeids_reported_determine_show_progress_info_show_progress_infor   Instant_collect_report_last_write_already_displayed_warnings_keyboardinterrupt_memo)r?   r   r   _pytestrB   rB   rC   r>   s  s0   







zTerminalReporter.__init__,Literal['progress', 'count', 'times', False]c                 C  sl   | 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
kr4d
S dS )zRReturn whether we should display progress information based on the current config.capturert   r   progress-even-when-capture-noF	setupshow>   r   r   r   r_   times)r   	getoptiongetini)r?   cfgrB   rB   rC   r     s   
z.TerminalReporter._determine_show_progress_infor   c                 C  s   | j jj}|S rQ   )r   r   r`   )r?   	verbosityrB   rB   rC   r     s   
zTerminalReporter.verbosityr7   c                 C  s
   | j dkS r   )r   r?   rB   rB   rC   
showheader     
zTerminalReporter.showheaderc                 C     t | jjjS rQ   )r7   r   r   rc   r   rB   rB   rC   rc        zTerminalReporter.no_headerc                 C  r   rQ   )r7   r   r   rd   r   rB   rB   rC   rd     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   rB   rB   rC   
showfspath  s   
zTerminalReporter.showfspathvaluebool | Nonec                 C  s
   || _ d S rQ   )r   )r?   r   rB   rB   rC   r     r   c                 C  s   | j tjdkS r   )r   r   r   r   r   rB   rB   rC   showlongtestinfo  s   z!TerminalReporter.showlongtestinfor   r3   c                 C  s   ddd ||}|| jv S )Nxr   )r*   r(   )getrj   )r?   r   rB   rB   rC   hasopt  s   
zTerminalReporter.hasoptr   res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   ru   write)r?   r   r   r  fspath	relfspathrB   rB   rC   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   ru   r  )r?   r  r  kwargsrB   rB   rC   write_ensure_prefix  s   


z$TerminalReporter.write_ensure_prefixc                 C  s   | j r| j  d | _ d S d S rQ   )r   r   ru   r   rB   rB   rC   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  wrappedrB   rB   rC   
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  rB   rB   rC   r    s   zTerminalReporter.writec                 C  s   | j   d S rQ   )r   r  r   rB   rB   rC   r    s   zTerminalReporter.flushru   str | bytesc                 K  s6   t |tst|dd}|   | jj|fi | d S )Nr   )errors)
isinstancer3   r  r   ru   )r?   ru   r  rB   rB   rC   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.
        eraseFrK   r   r   N)popr   r   lenr3   r  )r?   ru   r  r!  
fill_countfillrB   rB   rC   rewrite  s   	
 zTerminalReporter.rewriteseptitler9   r   
int | Nonec                 K  s$   |    | jj|||fi | d S rQ   )r  r   r(  )r?   r(  r)  r   r  rB   rB   rC   	write_sep  s   zTerminalReporter.write_sep=kwc                 K  s   | j j||fi | d S rQ   )r   r(  )r?   r)  r(  r-  rB   rB   rC   section$  s   zTerminalReporter.sectionr   c                 K  s   | j j|fi | d S rQ   )r   ru   )r?   r   r-  rB   rB   rC   ru   '     zTerminalReporter.linerX   itemsSequence[Any]c                 C  s2   || j v}| j |g | |r|   d S d S rQ   )r   
setdefaultextend_set_main_color)r?   rX   r0  set_main_colorrB   rB   rC   
_add_stats*  s
   
zTerminalReporter._add_statsexcreprr   c                 C  s&   t |dD ]	}| d|  qdS )Nr  zINTERNALERROR> T)r3   r  r   )r?   r7  ru   rB   rB   rC   pytest_internalerror0  s   z%TerminalReporter.pytest_internalerrorwarning_messagewarnings.WarningMessagec                 C  s@   ddl m} |j|jf}||}t|||d}| d|g d S )Nr   )warning_record_to_str)r   r   r   r,   )_pytest.warningsr;  r   linenor   r6  )r?   r9  r   r;  r   r   warning_reportrB   rB   rC   pytest_warning_recorded5  s   z(TerminalReporter.pytest_warning_recordedpluginr   c                 C  s&   | j jjrd| }| | d S d S )NzPLUGIN registered: )r   r   r   r   )r?   r@  r   rB   rB   rC   pytest_plugin_registeredD  s   

z)TerminalReporter.pytest_plugin_registeredSequence[Item]c                 C  s   |  d| d S )Nr)   )r6  )r?   r0  rB   rB   rC   pytest_deselectedL  s   z"TerminalReporter.pytest_deselectedlocationtuple[str, int | None, str]c                 C  sZ   |\}}}| j r| ||||}| |d |   d S | jr+| |d |   d S d S )Nr   )r   _locationliner  r  r   r
  )r?   r   rD  r  r=  domainru   rB   rB   rC   pytest_runtest_logstartO  s   
z(TerminalReporter.pytest_runtest_logstartr   r$   c                 C  sV  d| _ |}t| jjj|| jd }|j|j|j}}}t|t	s$d }n|\}}| 
||g |s5|s5d S |d u rdt|d}|jrH|sHddi}n|jrR|rRddi}n|jrZddi}n
|jrbddi}ni }| j|j | jtjdkr| jj|fi | | jr| js|   n| j|jg|jR  }	t|d}
|
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' d | jr
| jj| ( d dd n| jd | jj|fi | | jd|	  d| _)| *  d S )NT)r   r   wasxfailgreenyellowredr   node    [100%]rK   z ({})z ()[]r   )cyanr  )+
_tests_ranrW   r   hookr   rX   rY   rZ   r   tupler6  hasattrr'   r&   r(   r   addr   r   r   r   r   r  r   _is_last_item(_write_progress_information_if_past_edgerF  rD  r  _get_raw_skip_reasonr   r  r$  _format_trimmedr  r  r  rM  gatewayid!_get_progress_information_messager   r  )r?   r   repr   rX   rY   rZ   r  	was_xfailru   running_xdistreasonavailable_widthformatted_reasonrB   rB   rC   pytest_runtest_logreport]  s|   









z)TerminalReporter.pytest_runtest_logreportc                 C  s    | j d usJ t| j| j jkS rQ   )r   r$  r   testscollectedr   rB   rB   rC   rY    s   zTerminalReporter._is_last_itemT)wrapperGenerator[None, object, object]c                 c  s2    d V }| j tjdkr| jr| jr|   |S r   )r   r   r   r   r   r   r  )r?   resultrB   rB   rC   pytest_runtestloop  s   z#TerminalReporter.pytest_runtestloopc           
        sv  j sJ j j}jdkr4|r+tj}dtt| d}d| d}|||S d| d| dS jd	kr|s=d
S dd d d d d d
 }|d jd  fdd|D }t	 fddj j
D }t	 fdd|D }||k}	js|	rjdd |D  tt	dd |D S d
S |rdtjd | ddS dS )Nr_   z{:zd} [z/{}]z [  / z ]r   r   r'   r+   r&   r*   r(   r-   r   c                   s   g | ]
}|j  jvr|qS rB   )r   r   .0rr   rB   rC   
<listcomp>  s    zFTerminalReporter._get_progress_information_message.<locals>.<listcomp>c                 3  s    | ]
}|j d   kV  qdS )r   N)rD  )rp  icurrent_locationrB   rC   	<genexpr>  s    
zETerminalReporter._get_progress_information_message.<locals>.<genexpr>c                 3  s(    | ]}|j d   kr|jdkV  qdS )r   r   N)rD  r   ro  rt  rB   rC   rv    s    c                 s  s    | ]}|j V  qd S rQ   r   ro  rB   rB   rC   rv    s    c                 s  s     | ]}t |tr|jV  qd S rQ   )r   r$   durationro  rB   rB   rC   rv    s    d   3dz%]rO  )r   rg  r   r$  r   r3   format_get_reports_to_displayrD  sumr0  r   r   updateformat_node_duration)
r?   	collectedr   counter_formatformat_stringall_reportsnot_reportedtests_in_moduletests_completedlast_in_modulerB   )ru  r?   rC   r_    s\   



	

z2TerminalReporter._get_progress_information_messagec                 C  s   | j }| jdkr| jsJ | jj}td| d| d}n| jdkr'td}ntd}|| d | jk}|rP|  \}}|  }| jj	|d	 fi |d
i d S d S )Nr_   rl  /rR  r   z 99h 59mrO  rK   r  T)
_width_of_current_liner   r   rg  r$  r   _get_main_colorr_  r   r  )r?   r   	num_testsprogress_length	past_edge
main_color_r   rB   rB   rC   rZ    s   



 z9TerminalReporter._write_progress_information_if_past_edgec                 C  sN   |   \}}|  }| j}| jj| d }| j||fddi|di d S )NrK   r  T)r  r_  r  r   r   r  rjust)r?   r~   r  r   r   r&  rB   rB   rC   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   rB   rB   rC   r     s   z'TerminalReporter._width_of_current_linec                 C  sT   |   r| jjjdkr| jdddd d S d S | jjjdkr(| jdddd d S d S )Nr   zcollecting ... T)r  boldrK   )r   r   r   r`   r  r   rB   rB   rC   pytest_collection  s   z"TerminalReporter.pytest_collectionr#   c                 C  sd   |j r| d|g n
|jr| d|g dd |jD }|  jt|7  _|  r0|   d S d S )Nr-   r(   c                 S  s   g | ]	}t |tr|qS rB   )r   r   rp  r   rB   rB   rC   rr        z9TerminalReporter.pytest_collectreport.<locals>.<listcomp>)r&   r6  r(   rj  r   r$  r   report_collect)r?   r   r0  rB   rB   rC   pytest_collectreport  s   z%TerminalReporter.pytest_collectreportr   c                 C  sF  | j jjdk r	d S |s| j jtk rd S t | _t	| j
dg }t	| j
dg }t	| j
dg }| j| }|r>dnd}|t| jd | jdkrNd	nd
 7 }|rd|d| d|dkr_d
nd	 7 }|rn|d| d7 }|rx|d| d7 }| j|kr|d| d7 }|  r| j|ddd |r| d d S d S | | d S )Nr   r-   r(   r)   z
collected zcollecting z itemrK   r   r   rm  z errorz deselectedz skippedz	 selectedT)r  r!  r  )r   r   r`   r   elapsedsecondsREPORT_COLLECTING_RESOLUTIONr   r   r$  r   r   r   r3   r   r'  r  r   )r?   r   r  r(   r)   selectedru   rB   rB   rC   r    s<   


 
zTerminalReporter.report_collectr   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r  z	platform z -- Python pypy_version_infor      z[pypy--rR  z	, pytest-z	, pluggy-r   pastebinz -- )r   
start_path)r   r   r   _session_startr   r+  platformpython_versionrc   r   rM   r   r   r3   r   _versionversionpluggy__version__r   r   r   r   
executabler   rU  pytest_report_headerr   _write_report_lines_from_hooks)r?   r  verinfor   r  linesrB   rB   rC   pytest_sessionstart:  s2   


z$TerminalReporter.pytest_sessionstartr  Sequence[str | Sequence[str]]c                 C  s<   t |D ]}t|tr| | q|D ]}| | qqd S rQ   )reversedr   r3   r   )r?   r  line_or_linesru   rB   rB   rC   r  U  s   
z/TerminalReporter._write_report_lines_from_hooks	list[str]c                 C  s   d|j  g}|jr|dt|j |j  |jtjjkr-|d}|d	d
| |j }|rA|d	d
t| |S )Nz	rootdir: zconfigfile: 	testpathsztestpaths: {}, zplugins: {})r  inipathappendr!   args_sourcer   
ArgsSource	TESTPATHSr   r{  r   r   list_plugin_distinfo_plugin_nameversions)r?   r   rj  r  
plugininforB   rB   rC   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   r  r0  collectonlyrn  r   r&   !zcollection failures)r  r   rU  pytest_report_collectionfinishr   r0  r  r   r   r`   r   ru   _printcollecteditemsr   r   r(  
toterminal)r?   r  r  r&   r`  rB   rB   rC   pytest_collection_finishp  s(   

z)TerminalReporter.pytest_collection_finishc              	   C  s\  | j tj}|dk r>|dk r0tdd |D }t| D ]\}}| j| d|  qd S |D ]	}| j|j	 q2d S g }d}|D ]g}|
 dd  }	|ra||	d t| kr[n|  |sP|	t|d  D ]A}
||
 t|d d }| j| |
  |dkrt|
d	d }|rt|nd }|r| D ]}| jd
|d | qqiqDd S )Nr   rn  c                 s  s"    | ]}|j d dd V  qdS r  rK   r   N)r   r  )rp  itemrB   rB   rC   rv    s     z8TerminalReporter._printcollecteditems.<locals>.<genexpr>: r   rK     objz{}{})r   r   r   r   r   sortedr0  r   ru   r   	listchainr$  r#  r  rM   inspectgetdoc
splitlinesr{  )r?   r0  test_cases_verbositycountsnamer_   r  stackindentneeded_collectorscolr  docru   rB   rB   rC   r    s@   
z%TerminalReporter._printcollecteditems
exitstatusint | ExitCodeGenerator[None]c                 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)rL  )r   ru   r   OKTESTS_FAILEDINTERRUPTEDUSAGE_ERRORNO_TESTS_COLLECTEDrd   r   rU  pytest_terminal_summary
shouldfailr+  r3   _report_keyboardinterruptr   
shouldstopsummary_stats)r?   r  r  rj  summary_exit_codesrB   rB   rC   pytest_sessionfinish  s,   
z%TerminalReporter.pytest_sessionfinishc                 c  s^    |    |   |   |   |   |   zd V W |   |   S |   |   w rQ   )summary_errorssummary_failuressummary_xfailuressummary_warningssummary_passessummary_xpassesshort_test_summaryr   rB   rB   rC   r    s   

z(TerminalReporter.pytest_terminal_summaryexcinfoExceptionInfo[BaseException]c                 C  s   |j dd| _d S )NT)funcargs)getreprr   )r?   r  rB   rB   rC   pytest_keyboard_interrupt     z*TerminalReporter.pytest_keyboard_interruptc                 C  s   | j d ur|   d S d S rQ   )r   r  r   rB   rB   rC   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)rK  )
r   	reprcrashr   r+  r   r   	fulltracer  r   ru   )r?   r7  r   rB   rB   rC   r    s   

z*TerminalReporter._report_keyboardinterruptr  r=  rG  c                   sn   d fdd}|r1||}j dkr-|dd |d	tjkr-|d
tjt| 7 }|d S d}|d S )Nr   r3   r:   c                   s\   j | } r,| r,|d t   } d}|d dd|d< |d|7 }|S )NrQ  r   r   r  )r   cwd_relative_nodeidendswithr$  r  r   r   )r   ru   rH   rG  r?   rB   rC   mkrel  s   
z-TerminalReporter._locationline.<locals>.mkrelrN  r  r   \z <- z
[location]r   )r   r3   r:   r3   )r   r  r   r   SEPr!   r   r	   )r?   r   r  r=  rG  r  r   rB   r  rC   rF    s   
zTerminalReporter._locationlinec                 C  s   |j }|r|S dS )Nztest session)	head_line)r?   r`  r  rB   rB   rC   _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   )r3   longreprr  AttributeError)r?   r`  rB   rB   rC   _getcrashline  s   zTerminalReporter._getcrashliner  c                 C  s   dd | j |dD S )Nc                 S  s   g | ]	}t |d s|qS )	_pdbshown)rW  r  rB   rB   rC   rr    r  z/TerminalReporter.getreports.<locals>.<listcomp>rB   r   r   )r?   r  rB   rB   rC   
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 fdd}|rEd	nd
} jd|ddd |	 D ]2\}}	||	}
|
rw j
|
 | }ddd |D }| }n| } j
|  j
  qT j
d d S d S )Nr   r,   reportslist[WarningReport]r:   r3   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  )r3   r  )rp  locrB   rB   rC   rv  .  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{}rK   r   r   N)r{  )rp  kvrB   rB   rC   rv  1  s
    
)	r   r   r  r$  r   r   r3   r   r0  )r  	locationsr   rD  counts_by_filenamer   rB   rC   collapsed_location_report$  s   

zDTerminalReporter.summary_warnings.<locals>.collapsed_location_reportzwarnings summary (final)zwarnings summaryr,  TF)rK  r  r  c                 s  s    | ]}d | V  qdS )r  NrB   r  rB   rB   rC   rv  =  s    z4TerminalReporter.summary_warnings.<locals>.<genexpr>zG-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html)r  r  r:   r3   )r   r   r   r   r$  r2  r   r  r+  r0  r   ru   r  r   rstrip)r?   all_warningsr   warning_reportsreports_grouped_by_messagewrr  r)  r   message_reportsmaybe_locationr  indentedrB   r   rC   r    s>   



z!TerminalReporter.summary_warningsc                 C     |  ddd d S )Nr'   PASSESPsummary_passes_combinedr   rB   rB   rC   r  G  r  zTerminalReporter.summary_passesc                 C  r  )Nr+   XPASSESXr  r   rB   rB   rC   r  J  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 )Nrt   r,  r  T)rJ  r  )r   r   rp   r   r  r+  sectionsr  _outrep_summary_handle_teardown_sectionsr   )r?   r  r  r  r  r`  r   rB   rB   rC   r  M  s   



z(TerminalReporter.summary_passes_combinedlist[TestReport]c                   s   |  d} fdd|D S )Nr   c                   s$   g | ]}|j d kr|j kr|qS )r   )r   r   )rp  r   rw  rB   rC   rr  _  s
    z:TerminalReporter._get_teardown_reports.<locals>.<listcomp>)r  )r?   r   r  rB   rw  rC   _get_teardown_reports]  s   

z&TerminalReporter._get_teardown_reportsc                 C  s   |  |D ]}| | qd S rQ   )r#  print_teardown_sections)r?   r   r   rB   rB   rC   r!  e  s   z*TerminalReporter._handle_teardown_sectionsr`  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 )Nrt   r}   r   r  rn  r  )r   r   ry   r  r   r(  ru   r?   r`  ry   secnamer  rB   rB   rC   r$  i  s   
z(TerminalReporter.print_teardown_sectionsc                 C  s   | j jj}| jdd|d d S )Nr&   FAILURESro   )r   r   rp   summary_failures_combined)r?   ro   rB   rB   rC   r  v  s   
z!TerminalReporter.summary_failuresc                 C  s0   | j jj}|r| j jjnd}| jdd|d d S )Nrt   r*   	XFAILURESr(  )r   r   rx   rp   r)  )r?   show_tbro   rB   rB   rC   r  z  s   
z"TerminalReporter.summary_xfailures)r  ro   c          	      C  s   |dkrM|r|  |rO| |}|sd S | d| |dkr/|D ]}| |}| | q d S |D ]}| |}| jd|ddd | | | |j q1d S d S d S )Nrt   r,  ru   r  TrL  r  )	r   r  r+  r   r   r  r   r!  r   )	r?   r  r  ro   r  r  r`  ru   r   rB   rB   rC   r)    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 )Nrt   r-   r,  ERRORSr   zERROR collecting z	ERROR at z of r  Tr,  )	r   r   rp   r  r+  r   r  r   r   )r?   r  r`  r   rB   rB   rC   r    s   



zTerminalReporter.summary_errorsr"   c                 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 )Nrt   r}   r  rn  r  )r  r   r   r   ry   r  r(  ru   r%  rB   rB   rC   r     s   
z TerminalReporter._outrep_summaryc                 C  sN  | j dk rd S | 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j|fi |}|rh|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 )Nrn  r   r  Tz in r   z[0mr,  r   r   )r   r  r  build_summary_stats_liner   r   r  r$  r  r   format_session_durationr  r  r+  r   )r?   session_durationpartsr  
line_partsdisplay_sepr   textr  with_markupr   main_markuprx  duration_with_markupmarkup_for_end_seprB   rB   rC   r    s:   




zTerminalReporter.summary_statsc           
   	     s    j sd S d fdd}d fd	d
}d fdd}d fddd fddd fdd}||t|dd|t|ddt|ddd}g } j D ]}||}|rX|| qK|rn jddddd |D ]	}	 |	 qfd S d S )Nr  r  statr3   r:   r;   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   r`  r~   ru   r   rB   rC   show_simple  s   z8TerminalReporter.short_test_summary.<locals>.show_simplec           	            j dg }|D ]:}| jtd di\}} jj|fi |}t j j|}| d| }|j}|r>|dt	| 7 }| 
| q	d S )Nr*   r,   Tr    - r   r   _get_verbose_word_with_markupr   r<  r   r  _get_node_id_with_markuprI  r3   r  )	r  r*   r`  verbose_wordverbose_markupmarkup_wordr   ru   rc  r   rB   rC   show_xfailed  s   z9TerminalReporter.short_test_summary.<locals>.show_xfailedc           	        r@  )Nr+   r,   Tr   rA  rB  )	r  r+   r`  rE  rF  rG  r   ru   rc  r   rB   rC   show_xpassed  s   z9TerminalReporter.short_test_summary.<locals>.show_xpassedc                   s    j dg }|rt j|ng }|sd S |d  jtd di\}} jj|fi |}d}|D ];\}}}	}
|
	|rE|
t
|d  }
|	d ur]| | d| d| d|	 d	|
 	 q2| | d| d| d	|
  q2d S )
Nr(   r   r,   T	Skipped: rl  z] r   r  )r   r   _folded_skipsr   rC  r   r<  r   r  
startswithr$  r  )r  r(   fskipsrE  rF  rG  r  numr  r=  rc  r   rB   rC   show_skipped_folded  s    
("z@TerminalReporter.short_test_summary.<locals>.show_skipped_foldedc           	        s    j dg }|D ]^}|jd usJ t|jtsJ ||jft|jdks-J ||jf| jtd di\}} j	j
|fi |}t j	 j|}| d| }|jd }|rb|dt| 7 }| | q	d S )Nr(   r  r,   Tr   rN  rA  )r   r   r  r   rV  r$  rC  r   r<  r   r  rD  r3   r  )	r  r(   r`  rE  rF  rG  r   ru   rc  r   rB   rC   show_skipped_unfolded  s    
zBTerminalReporter.short_test_summary.<locals>.show_skipped_unfoldedc                   s    j r	|  d S |  d S rQ   )r   )r  r?   rO  rP  rB   rC   show_skipped+  s   z9TerminalReporter.short_test_summary.<locals>.show_skippedr&   )r;  r'   r-   )r   r  fr   pr   r,  zshort test summary infoT)rS  r  )r  r  r;  r3   r:   r;   )r  r  r:   r;   )rj   r   r   r+  r   )
r?   r?  rH  rI  rR  REPORTCHAR_ACTIONSr  r   ra   ru   rB   rQ  rC   r    s6   


	

z#TerminalReporter.short_test_summarytuple[str, list[str]]c                 C  sB   | j d u s| jd u s| jr|   | j sJ | jsJ | j | jfS rQ   )r   r   rY  r4  r   rB   rB   rC   r  E  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&   r-   rL  r,   r+   rK  r'   rJ  )r   rY  )r?   rW  r   r  rB   rB   rC   _determine_main_colorL  s   z&TerminalReporter._determine_main_colorc                 C  sP   g }| j D ]}|r|tvr||vr|| qtt| | _| t|| _d S rQ   )r   KNOWN_TYPESr  listr   rX  r7   r   )r?   unknown_types
found_typerB   rB   rC   r4  X  s   

z TerminalReporter._set_main_color-tuple[list[tuple[str, dict[str, bool]]], str]c                 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   rB   rB   rC   r0  a  s   z)TerminalReporter.build_summary_stats_linekey	list[Any]c                 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)rM   r  rB   rB   rC   rr  }  s    z<TerminalReporter._get_reports_to_display.<locals>.<listcomp>r  )r?   r`  r  rB   rB   rC   r|  z  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 )NTr  %d %szno tests ran)r  r|  r$  r<  r   r=  r  	pluralize)	r?   r  known_typesr3  r`  r  r_   r~   r  rB   rB   rC   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)   r-   r   zno tests collectedrK  TrJ  z%d %s collectedtestzno tests collected (z deselected)r  z tests collected (rb  )r$  r|  r   rc  r<  )r?   r)   r  r3  r  collected_outputall_tests_were_deselectedr  rB   rB   rC   r^    s*   


z7TerminalReporter._build_collect_only_summary_stats_linerQ   )r   r   r   r   r:   r;   )r:   r   )r:   r   )r:   r7   )r   r   r:   r;   )r   r3   r:   r7   )r   r3   r   r3   r  r7   r:   r;   r/  )r  r3   r  r3   r:   r;   )r:   r;   )r  r3   r  r7   r  r   r  r3   r  r7   r:   r;   )r  r3   r  r7   r  r7   r:   r;   )ru   r  r  r7   r:   r;   )ru   r3   r  r7   r:   r;   )NN)
r(  r3   r)  r9   r   r*  r  r7   r:   r;   )r,  )r)  r3   r(  r3   r-  r7   r:   r;   )r   r3   r-  r7   r:   r;   )rX   r3   r0  r1  r:   r;   )r7  r   r:   r7   )r9  r:  r   r3   r:   r;   )r@  r   r:   r;   )r0  rB  r:   r;   )r   r3   rD  rE  r:   r;   )r   r$   r:   r;   )r:   ri  )r:   r3   )r   r#   r:   r;   )F)r   r7   r:   r;   )r  r%   r:   r;   )r  r  r:   r;   )r   r   r:   r  )r  r%   r  r  r:   r  )r:   r  )r  r  r:   r;   )
r   r3   r  r3   r=  r*  rG  r3   r:   r3   )r  r3   )r  r3   r  r3   r  r3   r:   r;   )r   r3   r:   r"  )r   r3   r:   r;   )r`  r$   r:   r;   )
r  r3   r  r3   ro   r3   r  r9   r:   r;   )r`  r"   r:   r;   )r:   rV  )rW  r7   r:   r3   )r:   r]  )r`  r3   r:   ra  )MrR   rS   rT   r>   r   propertyr   r   rc   rd   r   setterr   r   r
  r  r  r  r  r  r   r'  r+  r.  ru   r6  r8  r?  rA  rC  rH  rf  rY  r   rk  r_  rZ  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rF  r  r   r  r  r  r  r  r#  r!  r$  r  r  r)  r  r   r  r  r  rX  r4  r0  r|  r_  r^  rB   rB   rB   rC   r   q  s    



		










L
-


$





6





%l
	r   twr   r`  c                 C  sB   | |j}|d^}}|r| jd|dd}|d | S |S )Nr  Tr  )r  r   r  r  r   )rj  r   r`  r   pathr3  parts_markuprB   rB   rC   rD    s   rD  r{  r   rd  r   r9   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  rn  Nz...r   )findr   r{  r$  )r{  r   rd  rs  ellipsisformat_widthrB   rB   rC   r\    s   

r\  word_markupdict[str, bool]c                 C  s   | | |\}}|j|fi |}t|| |}| d| }t|}	z|jjj}
W n
 ty3   Y |S w t s=| j	j
dkrG| j	jsGd|
 }
n|j|	 }td|
|}
|
durZ||
7 }|S )z?Get summary line for a report, trying to add reprcrash message.r   rN  rA  z - {}N)rC  r  rD  r   r  r  r   r  r   r   r`   rg   r   r\  )r   r`  rj  rp  rE  rF  rZ   rM  ru   
line_widthr   rd  rB   rB   rC   r>    s0   
r>  r   r	   r(   Sequence[CollectReport]&list[tuple[int, str, int | None, str]]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 )Nr  keywordsr   skip
pytestmark)r  r   rV  r$  r!   r	   rM   r   r2  r  r0  )r   r(   deventr  r=  rc  ru  r`  rH   eventsrB   rB   rC   rK    s$   

rK  rL  rK  rJ  )r&   r-   r,   r'   r_   nountuple[int, str]c                 C  s6   |dvr| |fS | dd}| | dkr|d fS |fS )N)r-   r,   re  r,   warningrK   r   )r   )r_   r{  rB   rB   rC   rc    s   rc  r  c                 C  sP   g }| D ]!\}}|j  d|j }|dr|dd  }||vr%|| q|S )Nr  zpytest-   )project_namer  rL  r  )r  rH   r@  distr  rB   rB   rC   r  +  s   

r  r  floatc                 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.<   .2fr   r  zs (rP  )datetime	timedeltar   )r  dtrB   rB   rC   r1  9  s   r1  c                 C  s   | dk rd| d ddS | dk rd| d ddS | dk r'd| d d	dS | d
k r4d| d ddS | dk rAd| d ddS | dk rNd| d d	dS | dk rYd| ddS | dk rld| d dd| d ddS d| d dd| d d ddS )zQFormat the given seconds in a human readable manner to show in the test progress.gh㈵>r   i@B z.3fusg-C6?r  gMbP?z.1fg{Gz?i  msg?rK   r  r   i  z.0fzm zh mrB   r  rB   rB   rC   r  B  s"   "r  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.
    rI  zreason: NrJ  Skippedr   )rW  rI  rL  r$  r(   r   r  rV  )r   rc  r  rB   rB   rC   r[  Y  s   



r[  )rD   r   r:   r;   )r   r   r:   r;   )r   r   r:   r3   )r   r"   r:   r   )rj  r   r   r   r`  r"   )r{  r3   r   r3   rd  r   r:   r9   )
r   r   r`  r"   rj  r   rp  rq  r:   r3   )r   r	   r(   rs  r:   rt  )r_   r   r{  r3   r:   r|  )r:   r  )r  r  r:   r3   )r   r$   r:   r3   )YrU   
__future__r   argparsecollectionsr   collections.abcr   r   r   r   dataclassesr  	functoolsr   r  pathlibr	   r  r   r  typingr
   r   r   r   r   r   r   r,   r  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%   r  rY  r   Actionr/   rW   r   r   r   r   	dataclassr   r   rD  r\  r>  rK  r<  r=  rc  r  r1  r  r[  rB   rB   rB   rC   <module>   s   %
 

        
I



  



	