
    [FiJ              
          d 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$ 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jX                  d#k  rdd$l-m.Z. erdd%l/m0Z0 dd&l1m2Z2 d'ed(dfd)Z3dJd*Z4dKd+Z5dKd,Z6d-e%d.ee%   d(e7fd/Z8	 dLd-e%d1e7d.ee%   d(ee   fd2Z9d-e%d(dfd3Z:d-e%d(dfd4Z;d-e%d(dfd5Z<d-e%d.ee%   d(dfd6Z=d-e%d7eed8      d(dfd9Z>d:ed(eee?e?e?f      fd;Z@	 dMd-e%d7ed8   d1e7d(efd<ZAd=d>d:ed(e7fd?ZB ed@d0A      ZCe	ej                   G dB dCe
eC                       ZEd-e%d=eEd   d(efdDZFdEe#d(efdFZG G dG dH      ZHdEe#d(efdIZIy)Nz3Basic collect and runtest protocol implementations.    N)Callable)cast)Dict)final)Generic)List)Literal)Optional)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )
BaseReport)CollectErrorRepr)CollectReport)
TestReport)timing)ExceptionChainRepr)ExceptionInfo)TerminalRepr)Parser)check_ispytest)	Collector)	Directory)Item)Node)Exit)OutcomeException)Skipped)TEST_OUTCOME)      )BaseExceptionGroup)Session)TerminalReporterparserreturnc                     | 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)r(   groups     `/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/_pytest/runner.pypytest_addoptionr;   5   sa    OO0+YOOE	OO@   
OO      c                    | j                   j                  j                  }| j                   j                  j                  }| j                   j	                  d      }|y | }g }|j
                  j                         D ]'  }|D ]   }t        |d      s|j                  |       " ) |sy |j                  d d       |s|j                  dd       n|j                  dd|z         |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verbosedurationc                     | j                   S N)r?   )xs    r:   <lambda>z)pytest_terminal_summary.<locals>.<lambda>X   s
    QZZ r<   T)keyreverse=zslowest durationszslowest %s durations    (z durations < gz,s hidden.  Use -vv to show these durations.)z02.2fzs z<8 )configoption	durationsdurations_mingetvaluestatsvalueshasattrappendsort	write_sep	enumerater?   
write_linelenwhennodeid)	terminalreporterrN   rO   r>   trdlistreplistrepis	            r:   pytest_terminal_summaryrb   J   sy    ''..88I$++22@@M%%..y9G	BE88??$ " 	"CsJ'S!	"" 	JJ'J6
S-.
S09<=jy!E" K3Q;3<<-7MM"MMCJN#=q0AAmn 
e,Bsxxm1SZZLIJKr<   c                 "    t               | _        y rA   )
SetupState_setupstatesessions    r:   pytest_sessionstartrh   i   s    $,Gr<   c                 :    | j                   j                  d        y rA   )re   teardown_exactrf   s    r:   pytest_sessionfinishrk   m   s    &&t,r<   itemnextitemc                     | j                   }|j                  | j                  | j                         t	        | |       |j                  | j                  | j                         y)N)r[   locationrm   T)ihookpytest_runtest_logstartr[   ro   runtestprotocolpytest_runtest_logfinish)rl   rm   rq   s      r:   pytest_runtest_protocolru   q   sN    JJE	!!t}}!MD8,	""$++"Nr<   Tlogc                    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                  t        | d||             |rd| _        d | _	        |S )	N_requestsetup	setupshowF	setuponlycallteardownrp   )
rS   rx   _initrequestcall_and_reportpassedrL   	getoptionshow_test_itemrT   funcargs)rl   rv   rm   
hasrequestr`   reportss         r:   rs   rs   y   s     z*J$-- 	
$
-CeG
zz;;  e44 {{$$[%8NN?4=>NN?4S8LM Nr<   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)
rL   get_terminal_writerlinewriter[   sortedgetattrformatjoinflush)rl   twused_fixturess      r:   r   r      sy    		(	(	*BGGIHHWHHT[[74<=M
'..tyy/GHIHHJr<   c                 f    t        | d       | j                  j                  j                  |        y )Nry   )_update_current_test_varrg   re   ry   )rl   s    r:   pytest_runtest_setupr      s$    T7+LL""4(r<   c                    t        | d       	 t        `t        `t        `t        j
                  dk\  rt        `	 | j                          y # t        $ r Y w xY w# t        $ rq}t        |      t        _        |t        _        t        j
                  dk\  r|t        _        |j                  J |j                  j                  t        _        |d }~ww xY w)Nr|   )r#      r   )r   sys	last_type
last_valuelast_tracebackversion_infolast_excAttributeErrorruntest	Exceptionr1   __traceback__tb_next)rl   es     r:   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 )Nr}   )r   rg   re   rj   )rl   rm   s     r:   pytest_runtest_teardownr      s.    T:.LL++H5T4(r<   rZ   )ry   r|   r}   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)r[   replaceosenvironpop)rl   rZ   var_namevalues       r:   r   r      sP     %H;;-r$q)fh/$

8


x r<   reportc                 V    | j                   dv r| j                  ry| j                  ryyy )N)ry   r}   )errorEERROR)skippedsSKIPPED)rH   rH   rH   )rZ   failedr   r   s    r:   pytest_report_teststatusr      s)    {{++==(^^,r<   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 )Nry   r|   r}   FzUnhandled runtest hook case: usepdbc                       dd iS )Nrl    r   )rl   kwdsruntest_hooks   r:   rC   z!call_and_report.<locals>.<lambda>   s    /$/$/ r<   )rZ   reraiserl   r|   r   noder|   r   )rq   r   r   r   r   rL   r   KeyboardInterruptCallInfo	from_callpytest_runtest_makereportpytest_runtest_logreportcheck_interactive_exceptionpytest_exception_interact)	rl   rZ   rv   r   rq   r   r|   r   r   s	   `  `    @r:   r   r      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Mr<   r|   zCallInfo[object]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)excinforS   
isinstancer   r!   bdbBdbQuit)r|   r   s     r:   r   r      sA     ||vz"$,,$$w&<=r<   TResult)	covariantc                   *   e Zd ZU dZee   ed<   eee      ed<   e	ed<   e	ed<   e	ed<   e
d   ed<   d	d
dee   deee      de	de	de	de
d   deddfdZedefd       Ze	 ddeg ef   de
d   deeee   eee   df   f      ddfd       ZdefdZy)r   z/Result/Exception info of a function invocation._resultr   startstopr?   )collectry   r|   r}   rZ   F)	_ispytestresultr   r)   Nc                n    t        |       || _        || _        || _        || _        || _        || _        y rA   )r   r   r   r   r   r?   rZ   )selfr   r   r   r   r?   rZ   r   s           r:   __init__zCallInfo.__init__  s6     	y!
	 	r<   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    r:   r   zCallInfo.result1  s4     <<# D8+?!@AA GT\\**r<   funcr   .zCallInfo[TResult]c           	      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)av  Call func, wrapping the result in a CallInfo.

        :param func:
            The function to call. Called without arguments.
        :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   r?   rZ   r   r   r   )r   timeperf_counterBaseExceptionr   from_currentr   r   )clsr   rZ   r   r   r   precise_startr   precise_stopr?   r   s              r:   r   zCallInfo.from_call>  s    & ++-	(,F **,-/{{}
 	
  	#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   rZ   r   r   s    r:   __repr__zCallInfo.__repr__i  sH    <<$TYYM4<<:J!LL Yt||6FaHHr<   rA   )__name__
__module____qualname____doc__r
   r   __annotations__r   r   r8   r	   boolr   propertyr   classmethodr   r   r   r   r   strr   r   r<   r:   r   r     sH    :gmM233L
KO
8
99  ! -67 	
   <=  
& 
+ 
+ 
+  (
r7{#(
 <=(
 $}%uT--@#-E'FFG
	(
 
(
 (
TI# Ir<   r   c                 .    t        j                  | |      S rA   )r   from_item_and_callr   s     r:   r   r   o  s    ((t44r<   	collectorc                 h    dt         t        t        t        f      f fd}t        j                  |d      }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} j1                  |j                        }	t3        |	d	      st        |	t(              sJ t5        |	      }	|	}|j                  s|j6                  nd }
t9         j:                  |||
      }||_        |S )
Nr)   c                  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   rL   pluginmanager_loadconftestmodulespathr   r   getinilistr   r   s   r:   r   z+pytest_make_collect_report.<locals>.collectt  s     i+**??  **<8"))22,5,<,<,C,C1-	 @  I%%'((r<   r   r   unittestr   r   r   
toterminal)r   r   r   r   r   r   r   r!   r   modulesgetrT   SkipTestr   r   tuple_repr_failure_pyr   repr	reprcrashr   r   linenomessagerepr_failurerS   r   r   r   r[   r|   )r   r   r|   longreproutcomeskip_exceptionsr  r_r	errorinfor   r`   s   `           r:   pytest_make_collect_reportr  s  sd   )T%i01 )& gy1DEIH<<: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Jr<   c                   \    e Zd ZdZddZdeddfdZdeg ef   de	ddfd	Z
d
ee   ddfdZy)rd   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!
    r)   Nc                     i | _         y rA   )stackr   s    r:   r   zSetupState.__init__  s      	
r<   rl   c                    |j                         }| j                  j                         D ]  \  }\  }}||v sJ d       |s| |t        | j                        d D ]?  }|| j                  vsJ |j                  gdf| j                  |<   	 |j                          A y# t        $ r(}| j                  |   d   |f| j                  |<   |d}~ww xY w)z4Setup objects along the collector chain to the item.z(previous item was not torn down properlyNr   )	listchainr  itemsrY   r}   ry   r"   )r   rl   needed_collectorscol
finalizersexcs         r:   ry   zSetupState.setup  s     NN, '+jj&6&6&8 	"C"*c++W-WW+		
 %S_%67 	Cdjj((( #~t4DJJsO			   #'::c?1#5s";

3	s   B  	C)#CC	finalizerr   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  rT   )r   r   r   s      r:   addfinalizerzSetupState.addfinalizer  s`    
 JtU333	"""tzz!5D$**#55!

4""9-r<   rm   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  keysrY   popitemr   r"   rT   extendr%   )r   rm   r  
exceptionsr   r  _these_exceptionsfinr   msgs              r:   rj   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)r)   N)r   r   r   r   r   r   ry   r   objectr   r#  r
   rj   r   r<   r:   rd   rd     sZ    =~
$ 4 *.hr6z&: .$ .4 . "x~  "$  "r<   rd   c                     | j                   }|j                  |        |j                  |       }|j                  j	                  dd       }|r t        ||      r|j                  | ||       |S )Nr  r|   r   )rq   pytest_collectstartr  __dict__r   r   r   )r   rq   r`   r|   s       r:   collect_one_noder2  2  sl    OOE		299I9NC<<FD)D+D#6''YT#'NJr<   )r\   r'   r)   N)rg   r&   r)   N)TN)T)Jr   r   dataclassesr   r   typingr   r   r   r   r   r   r	   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'   r;   rb   rh   rk   r   ru   rs   r   r   r   r   r   r   r   r   r   r   	dataclassr   r   r  rd   r2  r   r<   r:   <module>r?     s   9 
  	 
                % "   1 , + , - # #   ! - $ ) g1$1V  *K>'-$ (4. T  >B
,4TN	*0	 	$ 	)t ) )
d t 0)$ )(4. )T )!
!w'BCD!	!"	Z 	HU3S==Q4R 	" IM
9:AE4&8 * QU  )t
, ]Iww ]I  ]I@5D 5 5: 5.) . .bK" K"\	 m r<   