
    ?gK                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSKJ
r
  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSKJ#r#  SSK$J%r%  SSK$J&r&  SSK$J'r'  SSK$J(r(  \RR                  S:  a  SSK*J+r+  \(       a  SS K,J-r-  SS!K.J/r/  S:S" jr0S;S# jr1S<S$ jr2S<S% jr3S=S& jr4 S>       S?S( jjr5S@S) jr6S@S* jr7S@S+ jr8SAS, jr9      SBS- jr:SCS. jr; SD       SES/ jjr<SFS0 jr=\" S1S'S29r>\\R~                   " S3 S4\\>   5      5       5       r@SGS5 jrASHS6 jrB " S7 S85      rCSHS9 jrDg)Iz3Basic collect and runtest protocol implementations.    )annotationsN)Callable)cast)final)Generic)Literal)TYPE_CHECKING)TypeVar   )
BaseReport)CollectErrorRepr)CollectReport)
TestReport)timing)ExceptionChainRepr)ExceptionInfo)TerminalRepr)Parser)check_ispytest)	Collector)	Directory)Item)Node)Exit)OutcomeException)Skipped)TEST_OUTCOME)      )BaseExceptionGroup)Session)TerminalReporterc           	         U R                  SSSS9nUR                  SS[        S SSS	9  UR                  S
S[        SSSS	9  g )Nzterminal reporting	Reportinggeneral)afterz--durationsstoreNz1Show N slowest setup/test durations (N=0 for all))actiontypedefaultmetavarhelpz--durations-ming{Gzt?zJMinimal duration in seconds for inclusion in slowest list. Default: 0.005.)getgroup	addoptionintfloat)parsergroups     0/usr/lib/python3/dist-packages/_pytest/runner.pypytest_addoptionr5   2   sa    OO0+YOOE	OO@   
OO      c                6   U R                   R                  R                  nU R                   R                  R                  nU R                   R	                  5       nUc  g U n/ nUR
                  R                  5        H0  nU H'  n[        US5      (       d  M  UR                  U5        M)     M2     U(       d  g UR                  S SS9  U(       d  UR                  SS5        OUR                  SSU S35        US U n[        U5       H  u  pUS	:  aH  UR                  U:  a8  UR                  S
5        UR                  S[        U5      U-
   SUS S35          g UR                  UR                  S SUR                  S SUR                    35        M     g )Ndurationc                    U R                   $ N)r8   )xs    r4   <lambda>)pytest_terminal_summary.<locals>.<lambda>U   s    QZZr6   T)keyreverse=zslowest durationszslowest z
 durations    (z durations < gz,s hidden.  Use -vv to show these durations.)z02.2fzs z<8 )configoption	durationsdurations_minget_verbositystatsvalueshasattrappendsort	write_sep	enumerater8   
write_linelenwhennodeid)	terminalreporterrH   rI   verbosetrdlistreplistrepis	            r4   pytest_terminal_summaryr]   G   sj    ''..88I$++22@@M%%335G	BE88??$CsJ''S!  % 	JJ'J6
S-.
SHYKz:;jy!E"Q;3<<-7MM"MMCJN#=q0AAmn 
e,Bsxxm1SZZLIJ #r6   c                "    [        5       U l        g r:   )
SetupState_setupstatesessions    r4   pytest_sessionstartrc   f   s    $,Gr6   c                :    U R                   R                  S 5        g r:   )r`   teardown_exactra   s    r4   pytest_sessionfinishrf   j   s    &&t,r6   c                    U R                   nUR                  U R                  U R                  S9  [	        XS9  UR                  U R                  U R                  S9  g)N)rU   locationnextitemT)ihookpytest_runtest_logstartrU   rh   runtestprotocolpytest_runtest_logfinish)itemrj   rk   s      r4   pytest_runtest_protocolrp   n   sL    JJE	!!t}}!MD,	""$++"Nr6   Tc           	     P   [        U S5      nU(       a!  U R                  (       d  U R                  5         [        U SU5      nU/nUR                  (       ai  U R
                  R                  SS5      (       a  [        U 5        U R
                  R                  SS5      (       d  UR                  [        U SU5      5        U R                  R                  (       d  U R                  R                  (       a  S nUR                  [        U SXS95        U(       a  SU l        S U l        U$ )	N_requestsetup	setupshowF	setuponlycallteardownri   )rM   rr   _initrequestcall_and_reportpassedrF   	getoptionshow_test_itemrN   rb   
shouldfail
shouldstopfuncargs)ro   logrj   
hasrequestr[   reportss         r4   rm   rm   v   s     z*J$-- 	
$
-CeG
zz;;  e444 {{$$[%88NN?4=> ||$,,"9"9NN?4SLM Nr6   c                h   U R                   R                  5       nUR                  5         UR                  S5        UR                  U R                  5        [        [        U S/ 5      5      nU(       a/  UR                  SR                  SR                  U5      5      5        UR                  5         g)zAShow test function, parameters and the fixtures of the test item.z        fixturenamesz (fixtures used: {})z, N)
rF   get_terminal_writerlinewriterU   sortedgetattrformatjoinflush)ro   twused_fixturess      r4   r|   r|      sy    		(	(	*BGGIHHWHHT[[74<=M
'..tyy/GHIHHJr6   c                f    [        U S5        U R                  R                  R                  U 5        g )Nrs   )_update_current_test_varrb   r`   rs   )ro   s    r4   pytest_runtest_setupr      s$    T7+LL""4(r6   c                   [        U S5         [        ?[        ?[        ?[        R
                  S:  a  [        ? U R                  5         g ! [         a     Nf = f! [         ar  n[        U5      [        l        U[        l        [        R
                  S:  a  U[        l        UR                  c   eUR                  R                  [        l        e S nAff = f)Nrv   )r      r   )r   sys	last_type
last_valuelast_tracebackversion_infolast_excAttributeErrorruntest	Exceptionr*   __traceback__tb_next)ro   es     r4   pytest_runtest_callr      s    T6*MNz)    	Qz)CL***__44	s)   ,A A 
AA
C&A-CCc                ~    [        U S5        U R                  R                  R                  U5        [        U S 5        g )Nrw   )r   rb   r`   re   )ro   rj   s     r4   pytest_runtest_teardownr      s.    T:.LL++H5T4(r6   c                    SnU(       a8  U R                    SU S3nUR                  SS5      nU[        R                  U'   g[        R                  R	                  U5        g)zUpdate :envvar:`PYTEST_CURRENT_TEST` to reflect the current item and stage.

If ``when`` is None, delete ``PYTEST_CURRENT_TEST`` from the environment.
PYTEST_CURRENT_TESTz () z(null)N)rU   replaceosenvironpop)ro   rT   var_namevalues       r4   r   r      sP     %H;;-r$q)fh/$

8


x r6   c                n    U R                   S;   a%  U R                  (       a  gU R                  (       a  ggg )N)rs   rw   )errorEERROR)skippedsSKIPPED)rB   rB   rB   )rT   failedr   reports    r4   pytest_report_teststatusr      s)    {{++==(^^,r6   c                  ^ ^^ T R                   nUS:X  a  UR                  mO0US:X  a  UR                  mOUS:X  a  UR                  mO
 SU 35       e[        4nT R
                  R                  SS5      (       d
  U[        4-  n[        R                  U UU4S jXS9nUR                  T US	9nU(       a  UR                  US
9  [        Xg5      (       a  UR                  T XgS9  U$ )Nrs   rv   rw   FzUnhandled runtest hook case: usepdbc                    > T" SST 0TD6$ )Nro    r   )ro   kwdsruntest_hooks   r4   r<   !call_and_report.<locals>.<lambda>   s    /$/$/r6   )rT   reraisero   rv   r   noderv   r   )rk   r   r   r   r   rF   r{   KeyboardInterruptCallInfo	from_callpytest_runtest_makereportpytest_runtest_logreportcheck_interactive_exceptionpytest_exception_interact)	ro   rT   r   r   rk   r   rv   r   r   s	   `  `    @r4   ry   ry      s     JJEw,1,F,F	00		44<5dV<<u04wG;;  511%''/d  D 88d8NF
&&f&5"400''T'LMr6   c                    U R                   c  g[        US5      (       a  g[        U R                   R                  [        [
        R                  45      (       a  gg)zRCheck whether the call raised an exception that should be reported as
interactive.FwasxfailT)excinforM   
isinstancer   r   bdbBdbQuit)rv   r   s     r4   r   r      sG     ||vz""$,,$$w&<==r6   TResult)	covariantc                      \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S\S
'   S\S'   SS.               SS jjr\SS j5       r\	 S       SS jj5       r
SS jrSrg)r   i  z/Result/Exception info of a function invocation.TResult | None_result#ExceptionInfo[BaseException] | Noner   r1   startstopr8   /Literal['collect', 'setup', 'call', 'teardown']rT   F)	_ispytestc               b    [        U5        Xl        X l        X0l        X@l        XPl        X`l        g r:   )r   r   r   r   r   r8   rT   )selfresultr   r   r   r8   rT   r   s           r4   __init__CallInfo.__init__  s*     	y!
	 	r6   c                n    U R                   b  [        U < S35      e[        [        U R                  5      $ )z\The return value of the call, if it didn't raise.

Can only be accessed if excinfo is None.
z has no valid result)r   r   r   r   r   r   s    r4   r   CallInfo.result2  s4     <<# D8+?!@AA GT\\**r6   Nc           
     j   Sn[         R                  " 5       n[         R                  " 5       n U" 5       n[         R                  " 5       nX-
  n	[         R                  " 5       n
U " UU
U	UUUSS9$ ! [         a9    [        R
                  " 5       nUb  [        UR                  U5      (       a  e Sn N|f = f)ag  Call func, wrapping the result in a CallInfo.

:param func:
    The function to call. Called without arguments.
:type func: Callable[[], _pytest.runner.TResult]
:param when:
    The phase in which the function is called.
:param reraise:
    Exception or exceptions that shall propagate if raised by the
    function, instead of being wrapped in the CallInfo.
NT)r   r   r8   rT   r   r   r   )r   timeperf_counterBaseExceptionr   from_currentr   r   )clsfuncrT   r   r   r   precise_startr   precise_stopr8   r   s              r4   r   CallInfo.from_call?  s    $ ++-	%)VF **,/{{}
 	
  	#002G"z'--'I'IF		s   A/ /A B21B2c                    U R                   c  SU R                  < SU R                  < S3$ SU R                  < SU R                   < S3$ )Nz<CallInfo when=z	 result: >z	 excinfo=)r   rT   r   r   s    r4   __repr__CallInfo.__repr__i  sH    <<$TYYM4<<:J!LL Yt||6FaHHr6   )r   r8   r   r   r   rT   )r   r   r   r   r   r1   r   r1   r8   r1   rT   r   r   boolreturnNone)r   r   r:   )r   zCallable[[], TResult]rT   r   r   z<type[BaseException] | tuple[type[BaseException], ...] | Noner   zCallInfo[TResult])r   str)__name__
__module____qualname____firstlineno____doc____annotations__r   propertyr   classmethodr   r   __static_attributes__r   r6   r4   r   r     s     :00L
KO
99   5 	
   >  
& 
+ 
+ 
 QU	'
#'
 >'
 N	'

 
'
 '
RIr6   r   c                .    [         R                  " X5      $ r:   )r   from_item_and_callr   s     r4   r   r   o  s    ((44r6   c                  ^  S
U 4S jjn[         R                  US[        [        4S9nS nUR                  (       d  SnGOI[
        /n[        R                  R                  S5      nUb  UR                  UR                  5        [        UR                  R                  [        U5      5      (       a  SnT R                  UR                  S5      n[        U[        5      (       d   [!        U5      5       eUR"                  nU(       d   e[%        UR&                  5      UR(                  UR*                  4nORSnT R-                  UR                  5      n	[/        U	S	5      (       d"  [        U	[$        5      (       d   e[1        U	5      n	U	nUR                  (       d  UR2                  OS n
[5        T R6                  XCU
5      nX+l        U$ )Nc                 L  > [        T [        5      (       av  T R                  R                  R	                  T R
                  T R                  R                  S5      T R                  R                  T R                  R                  S5      S9  [        T R                  5       5      $ )N
importmodeconsider_namespace_packages)rootpathr  )r   r   rF   pluginmanager_loadconftestmodulespathr{   r  getinilistcollect	collectors   r4   r	  +pytest_make_collect_report.<locals>.collectt  s     i++**??  **<8"))22,5,<,<,C,C1-	 @  I%%'((r6   r	  )r   rz   unittestr   r   r   
toterminal)r   zlist[Item | Collector])r   r   r   
SystemExitr   r   r   modulesgetrN   SkipTestr   r   tuple_repr_failure_pyr   repr	reprcrashr   r  linenomessagerepr_failurerM   r   r   r   rU   rv   )r  r	  rv   longreproutcomeskip_exceptionsr  r_r	errorinfor   r[   s   `           r4   pytest_make_collect_reportr   s  sk   )& %6
$C  D BFH<<:B");;??:.""8#4#45dll((%*@AAG++DLL&ABb"455?tBx?5AH1AFFQXXqyy9HG!..t||<I9l33!)S1111,Y7	 H $T[[$F
	(('V
DCHJr6   c                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)r_   i  a  Shared state for setting up/tearing down test items or collectors
in a session.

Suppose we have a collection tree as follows:

<Session session>
    <Module mod1>
        <Function item1>
    <Module mod2>
        <Function item2>

The SetupState maintains a stack. The stack starts out empty:

    []

During the setup phase of item1, setup(item1) is called. What it does
is:

    push session to stack, run session.setup()
    push mod1 to stack, run mod1.setup()
    push item1 to stack, run item1.setup()

The stack is:

    [session, mod1, item1]

While the stack is in this shape, it is allowed to add finalizers to
each of session, mod1, item1 using addfinalizer().

During the teardown phase of item1, teardown_exact(item2) is called,
where item2 is the next item to item1. What it does is:

    pop item1 from stack, run its teardowns
    pop mod1 from stack, run its teardowns

mod1 was popped because it ended its purpose with item1. The stack is:

    [session]

During the setup phase of item2, setup(item2) is called. What it does
is:

    push mod2 to stack, run mod2.setup()
    push item2 to stack, run item2.setup()

Stack:

    [session, mod2, item2]

During the teardown phase of item2, teardown_exact(None) is called,
because item2 is the last item. What it does is:

    pop item2 from stack, run its teardowns
    pop mod2 from stack, run its teardowns
    pop session from stack, run its teardowns

Stack:

    []

The end!
c                    0 U l         g r:   stackr   s    r4   r   SetupState.__init__  s      	
r6   c                   UR                  5       nU R                  R                  5        H2  u  nu  pEX2;   d   S5       eU(       d  M  US   R                  US   5      e   U[	        U R                  5      S  HA  nX0R                  ;  d   eUR
                  /S4U R                  U'    UR                  5         MC     g! [         a2  nU R                  U   S   XUR                  44U R                  U'   e SnAff = f)z4Setup objects along the collector chain to the item.z(previous item was not torn down properlyr   r   N)		listchainr$  itemswith_tracebackrS   rw   rs   r   r   )r   ro   needed_collectorscol
finalizersexcs         r4   rs   SetupState.setup  s     NN, '+jj&6&6&8"C"*+W-WW+s!f++CF33 '9
 %S_%67Cjj((( #~t4DJJsO		 8   #'::c?1#5=N=N7O"P

3s   *B??
C;	-C66C;c                    U(       a  [        U[        5      (       a   e[        U5      (       d   eX R                  ;   d   X R                  45       eU R                  U   S   R	                  U5        g)zWAttach a finalizer to the given node.

The node must be currently active in the stack.
r   N)r   r  callabler$  rN   )r   	finalizerr   s      r4   addfinalizerSetupState.addfinalizer  sb    
 JtU3333	""""zz!5D**#55!

4""9-r6   c           	        U=(       a    UR                  5       =(       d    / n/ nU R                  (       a  [        U R                  R                  5       5      US[	        U R                  5       :X  a  OU R                  R                  5       u  nu  pV/ nU(       a!  UR                  5       n U" 5         U(       a  M!  [	        U5      S:X  a  UR                  U5        O-U(       a&  SU< 3n
UR                  [        XSSS2   5      5        U R                  (       a  M  [	        U5      S:X  a  US   eU(       a  [        SUSSS2   5      eUc  U R                  (       a   egg! [         a  n	UR                  U	5         Sn	A	NSn	A	ff = f)zTeardown the current stack up until reaching nodes that nextitem
also descends from.

When nextitem is None (meaning we're at the last item), the entire
stack is torn down.
Nr   zerrors while tearing down r   zerrors during test teardown)r'  r$  r  keysrS   popitemr   r   rN   extendr    )r   rj   r*  
exceptionsr   r,  _these_exceptionsfinr   msgs              r4   re   SetupState.teardown_exact  sY    %=););)=C*,
jjDJJOO%&*;<Mc$**o*NN$(JJ$6$6$8!D/:! nn&/E * #$)!!"23!24(;!!"4S4R4:P"QR! jjj$ z?aQ-$%BJtQStDTUUzz!>z  $ /$++A../s   -E# #
F-FFr#  N)r   r   ro   r   r   r   )r1  zCallable[[], object]r   r   r   r   )rj   Item | Noner   r   )
r   r   r   r   r   r   rs   r2  re   r   r   r6   r4   r_   r_     s    =~
*. "r6   r_   c                    U R                   nUR                  U S9  UR                  U S9nUR                  R	                  SS 5      nU(       a   [        X25      (       a  UR                  XUS9  U$ )Nr
  rv   r   )rk   pytest_collectstartr   __dict__r   r   r   )r  rk   r[   rv   s       r4   collect_one_noderD  4  sk    OOE		299I9NC<<FD)D+D66''Y#'NJr6   )r2   r   r   r   )rV   r"   r   r   )rb   r!   r   r   )ro   r   rj   r@  r   r   )TN)ro   r   r   r   rj   r@  r   zlist[TestReport]r?  )ro   r   rj   r@  r   r   )ro   r   rT   z+Literal['setup', 'call', 'teardown'] | Noner   r   )r   r   r   ztuple[str, str, str] | None)T)ro   r   rT   z$Literal['setup', 'call', 'teardown']r   r   r   r   )rv   zCallInfo[object]r   r   r   r   )ro   r   rv   zCallInfo[None]r   r   )r  r   r   r   )Er   
__future__r   r   dataclassesr   r   typestypingr   r   r   r   r   r	   r
   r   r   r   r   r   _pytestr   _pytest._code.coder   r   r   _pytest.config.argparsingr   _pytest.deprecatedr   _pytest.nodesr   r   r   r   _pytest.outcomesr   r   r   r   r   exceptiongroupr    _pytest.mainr!   _pytest.terminalr"   r5   r]   rc   rf   rp   rm   r|   r   r   r   r   r   ry   r   r   	dataclassr   r   r   r_   rD  r   r6   r4   <module>rS     s   9 " 
  	 
           % "   1 , + , - # #   ! - $ ) g1$1*K>'- ;?
,78	)
0)!
!A!	!"	" IM
:AE4 )t
, \Iww \I  \I~50fK" K"\r6   