
    9[gK                       d Z ddlmZ ddlZddl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m Z  ddlm!Z! ddlm"Z" ddlm#Z# ddl$m%Z% ddl$m&Z& ddl$m'Z' ddl$m(Z( ejR                  dk  rddl*m+Z+ erdd l,m-Z- dd!l.m/Z/ d:d"Z0d;d#Z1d<d$Z2d<d%Z3d=d&Z4	 d>	 	 	 	 	 	 	 d?d(Z5d@d)Z6d@d*Z7d@d+Z8dAd,Z9	 	 	 	 	 	 dBd-Z:dCd.Z;	 dD	 	 	 	 	 	 	 dEd/Z<dFd0Z= ed1d'2      Z>eej~                   G d3 d4ee>                       Z@dGd5ZAdHd6ZB G d7 d8      ZCdHd9ZDy)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                    | j                  ddd      }|j                  ddt        d dd	       |j                  d
dt        ddd	       y )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     I/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/runner.pypytest_addoptionr5   2   sa    OO0+YOOE	OO@   
OO      c                   | j                   j                  j                  }| j                   j                  j                  }| j                   j	                         }|y | }g }|j
                  j                         D ]'  }|D ]   }t        |d      s|j                  |       " ) |sy |j                  d d       |s|j                  dd       n|j                  dd| d       |d | }t        |      D ]  \  }}|d	k  rG|j                  |k  r8|j                  d
       |j                  dt        |      |z
   d|dd        y |j                  |j                  dd|j                  dd|j                            y )Ndurationc                    | j                   S N)r8   )xs    r4   <lambda>z)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)	terminalreporterrG   rH   verbosetrdlistreplistrepis	            r4   pytest_terminal_summaryr\   G   si    ''..88I$++22@@M%%335G	BE88??$CsJ'S!  % 	JJ'J6
S-.
SHYKz:;jy!E"3Q;3<<-7MM"MMCJN#=q0AAmn 
e,Bsxxm1SZZLIJ #r6   c                "    t               | _        y r:   )
SetupState_setupstatesessions    r4   pytest_sessionstartrb   f   s    $,Gr6   c                :    | j                   j                  d        y r:   )r_   teardown_exactr`   s    r4   pytest_sessionfinishre   j   s    &&t,r6   c                    | j                   }|j                  | j                  | j                         t	        | |       |j                  | j                  | j                         y)N)rT   locationnextitemT)ihookpytest_runtest_logstartrT   rg   runtestprotocolpytest_runtest_logfinish)itemri   rj   s      r4   pytest_runtest_protocolro   n   sN    JJE	!!t}}!MD8,	""$++"Nr6   Tc                   t        | d      }|r| j                  s| j                          t        | d|      }|g}|j                  r_| j
                  j                  dd      rt        |        | j
                  j                  dd      s|j                  t        | d|             | j                  j                  s| j                  j                  rd }|j                  t        | d||             |rd| _        d | _        |S )	N_requestsetup	setupshowF	setuponlycallteardownrh   )rL   rq   _initrequestcall_and_reportpassedrE   	getoptionshow_test_itemrM   ra   
shouldfail
shouldstopfuncargs)rn   logri   
hasrequestrZ   reportss         r4   rl   rl   v   s     z*J$-- 	
$
-CeG
zz;;  e44 {{$$[%8NN?4=> ||$,,"9"9NN?4S8LM Nr6   c                ^   | j                   j                         }|j                          |j                  d       |j                  | j                         t        t        | dg             }|r/|j                  dj                  dj                  |                   |j                          y)zAShow test function, parameters and the fixtures of the test item.z        fixturenamesz (fixtures used: {})z, N)
rE   get_terminal_writerlinewriterT   sortedgetattrformatjoinflush)rn   twused_fixturess      r4   r{   r{      sy    		(	(	*BGGIHHWHHT[[74<=M
'..tyy/GHIHHJr6   c                f    t        | d       | j                  j                  j                  |        y )Nrr   )_update_current_test_varra   r_   rr   )rn   s    r4   pytest_runtest_setupr      s$    T7+LL""4(r6   c                   t        | d       	 t        `t        `t        `t        j
                  dk\  rt        `	 | j                          y # t        $ r Y w xY w# t        $ rp}t        |      t        _        |t        _        t        j
                  dk\  r|t        _        |j                  J |j                  j                  t        _         d }~ww xY w)Nru   )r      r   )r   sys	last_type
last_valuelast_tracebackversion_infolast_excAttributeErrorruntest	Exceptionr*   __traceback__tb_next)rn   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                ~    t        | d       | j                  j                  j                  |       t        | d        y )Nrv   )r   ra   r_   rd   )rn   ri   s     r4   pytest_runtest_teardownr      s.    T:.LL++H5T4(r6   c                    d}|r8| j                    d| d}|j                  dd      }|t        j                  |<   yt        j                  j	                  |       y)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)rT   replaceosenvironpop)rn   rS   var_namevalues       r4   r   r      sP     %H;;-r$q)fh/$

8


x r6   c                V    | j                   dv r| j                  ry| j                  ryyy )N)rr   rv   )errorEERROR)skippedsSKIPPED)rA   rA   rA   )rS   failedr   reports    r4   pytest_report_teststatusr      s)    {{++==(^^,r6   c                     j                   }|dk(  r|j                  n.|dk(  r|j                  n|dk(  r|j                  n
J d|        t        f} j
                  j                  dd      s
|t        fz  }t        j                   fd||      }|j                   |	      }|r|j                  |
       t        ||      r|j                   ||       |S )Nrr   ru   rv   FzUnhandled runtest hook case: usepdbc                      dd iS )Nrn    r   )rn   kwdsruntest_hooks   r4   r<   z!call_and_report.<locals>.<lambda>   s    /$/$/r6   )rS   reraisern   ru   r   noderu   r   )rj   r   r   r   r   rE   rz   KeyboardInterruptCallInfo	from_callpytest_runtest_makereportpytest_runtest_logreportcheck_interactive_exceptionpytest_exception_interact)	rn   rS   r   r   rj   r   ru   r   r   s	   `  `    @r4   rx   rx      s     JJEw,1,F,F	00		44<5dV<<u04wG;;  51%''/dG  D 88d8NF
&&f&5"40''TV'LMr6   c                    | j                   yt        |d      ryt        | j                   j                  t        t
        j                  f      ryy)zVCheck whether the call raised an exception that should be reported as
    interactive.FwasxfailT)excinforL   
isinstancer   r   bdbBdbQuit)ru   r   s     r4   r   r      sA     ||vz"$,,$$w&<=r6   TResult)	covariantc                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   dd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Ze	 d	 	 	 	 	 	 	 dd       Z	ddZ
y)r   z/Result/Exception info of a function invocation.TResult | None_result#ExceptionInfo[BaseException] | Noner   r1   startstopr8   /Literal['collect', 'setup', 'call', 'teardown']rS   F)	_ispytestc               n    t        |       || _        || _        || _        || _        || _        || _        y r:   )r   r   r   r   r   r8   rS   )selfresultr   r   r   r8   rS   r   s           r4   __init__zCallInfo.__init__  s6     	y!
	 	r6   c                j    | j                   t        | d      t        t        | j                        S )zlThe 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   zCallInfo.result2  s4     <<# D8+?!@AA GT\\**r6   Nc           	     Z   d}t        j                         }t        j                         }	  |       }t        j                         }||z
  }	t        j                         }
 | ||
|	|||d      S # t        $ r2 t	        j
                         }|t        |j                  |      r d}Y vw xY w)a  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   rS   r   r   r   )r   timeperf_counterBaseExceptionr   from_currentr   r   )clsfuncrS   r   r   r   precise_startr   precise_stopr8   r   s              r4   r   zCallInfo.from_call?  s    $ ++-	%)VF **,-/{{}
 	
  	#002G"z'--'IF		s   A/ /8B*)B*c                    | j                   d| j                  d| j                  dS d| j                  d| j                   dS )Nz<CallInfo when=z	 result: >z	 excinfo=)r   rS   r   r   s    r4   __repr__zCallInfo.__repr__i  sH    <<$TYYM4<<:J!LL Yt||6FaHHr6   )r   r   r   r   r   r1   r   r1   r8   r1   rS   r   r   boolreturnNone)r   r   r:   )r   zCallable[[], TResult]rS   r   r   z<type[BaseException] | tuple[type[BaseException], ...] | Noner   zCallInfo[TResult])r   str)__name__
__module____qualname____doc____annotations__r   propertyr   classmethodr   r   r   r6   r4   r   r     s     :00L
KO
99   5 	
   >  
& 
+ 
+ 
 QU	'
#'
 >'
 N	'

 
'
 '
RIr6   r   c                .    t        j                  | |      S r:   )r   from_item_and_callr   s     r4   r   r   o  s    ((t44r6   c                L    d
 fd}t         j                  |dt        t        f      }d }|j                  sd}n/t
        g}t        j                  j                  d      }||j                  |j                         t        |j                  j                  t        |            r{d} j                  |j                  d      }t        |t              sJ t!        |             |j"                  }|sJ t%        |j&                        |j(                  |j*                  f}nHd} j-                  |j                        }	t/        |	d	      st        |	t$              sJ t1        |	      }	|	}|j                  s|j2                  nd }
t5         j6                  |||
      }||_        |S )Nc                 H   t         t              ry j                  j                  j	                   j
                   j                  j                  d       j                  j                   j                  j                  d             t         j                               S )N
importmodeconsider_namespace_packages)rootpathr   )r   r   rE   pluginmanager_loadconftestmodulespathrz   r   getinilistcollect	collectors   r4   r  z+pytest_make_collect_report.<locals>.collectt  s     i+**??  **<8"))22,5,<,<,C,C1-	 @  I%%'((r6   r  )r   ry   unittestr   r   r   
toterminal)r   zlist[Item | Collector])r   r   r   
SystemExitr   r   r   modulesgetrM   SkipTestr   r   tuple_repr_failure_pyr   repr	reprcrashr   r   linenomessagerepr_failurerL   r   r   r   rT   ru   )r  r  ru   longreproutcomeskip_exceptionsr  r_r	errorinfor   rZ   s   `           r4   pytest_make_collect_reportr  s  sc   )& %6
$C  D BFH<<:B");;??:.""8#4#45dll((%*@AG++DLL&ABb"45?tBx?5AH1AFFQXXqyy9HG!..t||<I9l3!)S111,Y7	 H $T[[$F
	(('8V
DCCHJr6   c                  0    e Zd ZdZddZddZd	dZd
dZy)r^   aE  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                    i | _         y r:   )stackr   s    r4   r   zSetupState.__init__  s      	
r6   c                   |j                         }| j                  j                         D ],  \  }\  }}||v sJ d       |s|d   j                  |d          |t	        | j                        d D ]?  }|| j                  vsJ |j
                  gdf| j                  |<   	 |j                          A y# t        $ r3}| j                  |   d   ||j                  ff| j                  |<    d}~ww xY w)z4Setup objects along the collector chain to the item.z(previous item was not torn down properlyr   r   N)		listchainr  itemswith_tracebackrR   rv   rr   r   r   )r   rn   needed_collectorscol
finalizersexcs         r4   rr   zSetupState.setup  s     NN, '+jj&6&6&8"C"*c++W-WW+!f++CF33 '9
 %S_%67Cdjj((( #~t4DJJsO		 8   #'::c?1#5S=N=N7O"P

3s   "B55	C1>.C,,C1c                    |rt        |t              rJ t        |      sJ || j                  v sJ || j                  f       | j                  |   d   j	                  |       y)zgAttach a finalizer to the given node.

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

4""9-r6   c           	        |xr |j                         xs g }g }| j                  rt        | j                  j                               |dt	        | j                         k(  rn| j                  j                         \  }\  }}g }|r|j                         }	  |        |rt	        |      dk(  r|j                  |       n(|r&d|}
|j                  t        |
|ddd                | j                  rt	        |      dk(  r|d   |rt        d|ddd         || j                  rJ yy# t        $ r}	|j                  |	       Y d}	~	d}	~	ww xY w)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   keysrR   popitemr   r   rM   extendr    )r   ri   r  
exceptionsr   r!  _these_exceptionsfinr   msgs              r4   rd   zSetupState.teardown_exact  sZ    %=););)=C*,
jjDJJOO%&*;<Mc$**o*NN$(JJ$6$6$8!D/:q! nn&/E  #$)!!"23!24(;!!"4S:J4R4:P"QR! jj$ z?aQ-$%BJtQStDTUUzz!>z  $ /$++A../s   D1 1	E:EEN)r   r   rn   r   r   r   )r%  zCallable[[], object]r   r   r   r   )ri   Item | Noner   r   )r   r   r   r   r   rr   r&  rd   r   r6   r4   r^   r^     s    =~
*. "r6   r^   c                    | j                   }|j                  |        |j                  |       }|j                  j	                  dd       }|r t        ||      r|j                  | ||       |S )Nr  ru   r   )rj   pytest_collectstartr  __dict__r   r   r   )r  rj   rZ   ru   s       r4   collect_one_noder6  4  sl    OOE		299I9NC<<FD)D+D#6''YT#'NJr6   )r2   r   r   r   )rU   r"   r   r   )ra   r!   r   r   )rn   r   ri   r2  r   r   )TN)rn   r   r   r   ri   r2  r   zlist[TestReport]r1  )rn   r   ri   r2  r   r   )rn   r   rS   z+Literal['setup', 'call', 'teardown'] | Noner   r   )r   r   r   ztuple[str, str, str] | None)T)rn   r   rS   z$Literal['setup', 'call', 'teardown']r   r   r   r   )ru   zCallInfo[object]r   r   r   r   )rn   r   ru   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\   rb   re   ro   rl   r{   r   r   r   r   r   rx   r   r   	dataclassr   r   r  r^   r6  r   r6   r4   <module>rE     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   