
    BhWL                       d 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	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jT                  dk  rddl+m,Z, erdd l-m.Z. dd!l/m0Z0 d:d"Z1d;d#Z2d<d$Z3d<d%Z4d=d&Z5	 d>	 	 	 	 	 	 	 d?d(Z6d@d)Z7d@d*Z8d@d+Z9dAd,Z:	 	 	 	 	 	 dBd-Z;dCd.Z<	 dD	 	 	 	 	 	 	 dEd/Z=dFd0Z> ed1d'2      Z?eej                   G d3 d4ee?                       ZAdGd5ZBdHd6ZC G d7 d8      ZDdHd9ZEy)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-minzcMinimal duration in seconds for inclusion in slowest list. Default: 0.005 (or 0.0 if -vv is given).)getgroup	addoptionintfloat)parsergroups     Y/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/_pytest/runner.pypytest_addoptionr5   2   sa    OO0+YOOE	OO@   
OO3      c                p   | j                   j                  j                  }| j                   j                  j                  }| j                   j	                         }|y |	|dk  rdnd}| }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 ]  \  }}|j                  |k  rd|j                  d       dt        |      |z
   d|dd}	| j                   j                  j                  |	dz  }	|	dz  }	|j                  |	        y |j                  |j                  dd|j                  dd|j                            y )N   g{Gzt?g        durationc                    | j                   S N)r9   )xs    r4   <lambda>z)pytest_terminal_summary.<locals>.<lambda>W   s    QZZr6   T)keyreverse=zslowest durationszslowest z
 durations (z durations < gz	s hidden.z"  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	enumerater9   
write_linelenwhennodeid)
terminalreporterrH   rI   verbosetrdlistreplistrepimessages
             r4   pytest_terminal_summaryr^   G   s    ''..88I$++22@@M%%335G!(1#	BE88??$CsJ'S!  % 	JJ'J6
S-.
SHYKz:;jy!E"3<<-'MM"#e*q.)}Q6GyQG&&--;;C??sNGMM'"
e,Bsxxm1SZZLIJ #r6   c                "    t               | _        y r;   )
SetupState_setupstatesessions    r4   pytest_sessionstartrd   j   s    $,Gr6   c                :    | j                   j                  d        y r;   )ra   teardown_exactrb   s    r4   pytest_sessionfinishrg   n   s    &&t,r6   c                    | j                   }|j                  | j                  | j                         t	        | |       |j                  | j                  | j                         y)N)rU   locationnextitemT)ihookpytest_runtest_logstartrU   ri   runtestprotocolpytest_runtest_logfinish)itemrk   rl   s      r4   pytest_runtest_protocolrq   r   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teardownrj   )rM   rs   _initrequestcall_and_reportpassedrF   	getoptionshow_test_itemrN   rc   
shouldfail
shouldstopfuncargs)rp   logrk   
hasrequestr[   reportss         r4   rn   rn   z   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)
rF   get_terminal_writerlinewriterU   sortedgetattrformatjoinflush)rp   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 )Nrt   )_update_current_test_varrc   ra   rt   )rp   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)Nrw   )r      r   )r   sys	last_type
last_valuelast_tracebackversion_infolast_excAttributeErrorruntest	Exceptionr*   __traceback__tb_next)rp   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 )Nrx   )r   rc   ra   rf   )rp   rk   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 (rD    z(null)N)rU   replaceosenvironpop)rp   rT   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)rt   rx   )errorEERROR)skippedsSKIPPED)rA   rA   rA   )rT   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 )Nrt   rw   rx   FzUnhandled runtest hook case: usepdbc                      dd iS )Nrp    r   )rp   kwdsruntest_hooks   r4   r=   z!call_and_report.<locals>.<lambda>   s    /$/$/r6   )rT   reraiserp   rw   r   noderw   r   )rl   r   r   r   r   rF   r|   KeyboardInterruptCallInfo	from_callpytest_runtest_makereportpytest_runtest_logreportcheck_interactive_exceptionpytest_exception_interact)	rp   rT   r   r   rl   r   rw   r   r   s	   `  `    @r4   rz   rz      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)excinforM   
isinstancer   r   bdbBdbQuit)rw   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stopr9   /Literal['collect', 'setup', 'call', 'teardown']rT   F)	_ispytestc               n    t        |       || _        || _        || _        || _        || _        || _        y r;   )r   r   r   r   r   r9   rT   )selfresultr   r   r   r9   rT   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.result6  s4     <<# D8+?!@AA GT\\**r6   Nc           	     \   d}t        j                         }	  |       }|j                         } | |j                  j                  |j                  j                  |j                  |||d      S # t        $ r2 t        j                         }|t        |j                  |      r d}Y w 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   r9   rT   r   r   r   )r   InstantBaseExceptionr   from_currentr   r   elapsedr   timer   seconds)clsfuncrT   r   r   instantr   r9   s           r4   r   zCallInfo.from_callC  s    $ .."	%)VF ??$..%%##%%
 	
  	#002G"z'--'IF		s   A0 08B+*B+c                    | j                   d| j                  d| j                  dS d| j                  d| j                   dS )Nz<CallInfo when=z	 result: >z	 excinfo=)r   rT   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   r9   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____doc____annotations__r   propertyr   classmethodr   r   r   r6   r4   r   r     s     :00L
KO
99   5 	
   >  
& 
+ 
+ 
 QU	#
##
 >#
 N	#

 
#
 #
J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   rF   pluginmanager_loadconftestmodulespathr|   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   r{   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   linenor]   repr_failurerM   r   r   r   rU   rw   )r  r  rw   longreproutcomeskip_exceptionsr  r_r	errorinfor   r[   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_tracebackrS   rx   rt   r   r   )r   rp   needed_collectorscol
finalizersexcs         r4   rt   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  rN   )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  keysrS   popitemr   r   rN   extendr    )r   rk   r   
exceptionsr   r"  _these_exceptionsfinr   msgs              r4   rf   zSetupState.teardown_exact  sZ    &>(*<*<*>E2*,
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   rp   r   r   r   )r&  zCallable[[], object]r   r   r   r   )rk   Item | Noner   r   )r   r   r   r   r   rt   r'  rf   r   r6   r4   r`   r`     s    =~
*. "r6   r`   c                    | j                   }|j                  |        |j                  |       }|j                  j	                  dd       }|r t        ||      r|j                  | ||       |S )Nr  rw   r   )rl   pytest_collectstartr  __dict__r   r   r   )r  rl   r[   rw   s       r4   collect_one_noder7  4  sl    OOE		299I9NC<<FD)D+D#6''YT#'NJr6   )r2   r   r   r   )rV   r"   r   r   )rc   r!   r   r   )rp   r   rk   r3  r   r   )TN)rp   r   r   r   rk   r3  r   zlist[TestReport]r2  )rp   r   rk   r3  r   r   )rp   r   rT   z+Literal['setup', 'call', 'teardown'] | Noner   r   )r   r   r   ztuple[str, str, str] | None)T)rp   r   rT   z$Literal['setup', 'call', 'teardown']r   r   r   r   )rw   zCallInfo[object]r   r   r   r   )rp   r   rw   zCallInfo[None]r   r   )r  r   r   r   )Fr   
__future__r   r   collections.abcr   dataclassesr   r   typestypingr   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^   rd   rg   rq   rn   r}   r   r   r   r   r   rz   r   r   	dataclassr   r   r  r`   r7  r   r6   r4   <module>rG     s   9 " 
 $  	 
          % "   1 , + , - # #   ! - $ ) g1$1* KF'- ;?
,78	)
0)!
!A!	!"	" IM
:AE4 )t
, XIww XI  XIv50fK" K"\r6   