
    	h4                     0   d 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  erddl!m"Z" ddl#m$Z$ de%dee%e%f         fdZ&deddfdZ'deddfdZ( G d d           Z) G d! d"          Z* G d# d$          Z+d% Z,d& Z-d'ed(ee.         d)e de fd*Z/d(ee.         dej0        fd+Z1d,ej0        ddfd-Z2dS ).z4Interactive debugging with PDB, the Python Debugger.    N)Any)Callable)	Generator)List)Optional)Tuple)Type)TYPE_CHECKING)Union)outcomes)ExceptionInfo)Config)ConftestImportFailure)hookimpl)PytestPluginManager)Parser)
UsageError)Node)
BaseReport)CaptureManager)CallInfovaluereturnc                     	 |                      d          \  }}n*# t          $ r}t          j        | d          |d}~ww xY w||fS )z#Validate syntax of --pdbcls option.:z) is not in the format 'modname:classname'N)split
ValueErrorargparseArgumentTypeError)r   modname	classnamees       ^/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/_pytest/debugging.py_validate_usepdb_clsr$   !   so    "[[--   (AAA
 
	 Ys    
A=Aparserc                     |                      d          }|                    dddd           |                    ddd	t          d
           |                    dddd           d S )Ngeneralz--pdbusepdb
store_truezDStart the interactive Python debugger on errors or KeyboardInterrupt)destactionhelpz--pdbcls
usepdb_clszmodulename:classnamez{Specify a custom interactive Python debugger for use with --pdb.For example: --pdbcls=IPython.terminal.debugger:TerminalPdb)r*   metavartyper,   z--tracetracez(Immediately break when running each test)getgroup
_addoptionr$   )r%   groups     r#   pytest_addoptionr4   ,   s    OOI&&E	S	     
&!F     
7	          configc                    dd l |                     d          r'| j                            t	                      d           |                     d          r'| j                            t                      d           t          j                            j	        t          j
        t          j        f           t          j	        _	        | j        t          _
        | t          _        dfd}|                     |           d S )	Nr   r0   pdbtracer(   	pdbinvoker   c                  ~    t           j                                        \   _        t           _        t           _        d S N)	pytestPDB_savedpop	set_trace_pluginmanager_config)pdbs   r#   finzpytest_configure.<locals>.finU   s3    
   ""		
M$r5   r   N)rB   getvaluepluginmanagerregisterPdbTrace	PdbInvoker<   r=   appendr?   r@   rA   add_cleanup)r6   rC   rB   s     @r#   pytest_configurerL   D   s    JJJw >%%hjj*===x   @%%ikk;???		0)2CD   'CM%3II# # # # # # sr5   c                      e Zd ZU dZdZee         ed<   dZee	         ed<   g Z
eeed         ee         ee	         f                  ed<   dZdZeeee         ee         f                  ed<   ed	ed
         deeef         fd            Zed	ed
         fd            Zed	ed
         fd            Zed             Zedd            ZdS )r<   z'Pseudo PDB that defers to the real pdb.Nr@   rA   ).Nr=   r   _wrapped_pdb_clscapmanr   r   c                 2    |r|                                 S dS )NF)is_capturing)clsrO   s     r#   _is_capturingzpytestPDB._is_capturingj   s!     	)&&(((ur5   c                 ^   | j         sdd l}|j        S | j                             d          }| j        r| j        d         |k    r| j        d         S |r|\  }}	 t          |           t          j        |         }|                    d          }t          ||d                   }|dd          D ]}	t          ||	          }nJ# t          $ r2}
d                    ||f          }t          d|d|
           |
d }
~
ww xY wdd l}|j        }|                     ||          }||f| _        |S )Nr   r-      .r   z--pdbcls: could not import z: )rA   rB   PdbrE   rN   
__import__sysmodulesr   getattr	Exceptionjoinr   _get_pdb_wrapper_class)rR   rO   rB   r-   r    r!   modpartspdb_clspartexcr   wrapped_clss                r#   _import_pdb_clszpytestPDB._import_pdb_clsp   sy   { 	JJJ 7N[)),77
 	+C$8$;z$I$I'** 	!+GY7###k'* ",,!#uQx00!!""I 5 5D%gt44GG5   '9!566 B%BBSBB  JJJgG00&AA *K8s   A)C 
D -C;;D c                 8     dd l  G  fdd|          }|S )Nr   c                   h     e Zd ZZdZ fdZ fdZexZZ fdZ	e	Z
e	Z fdZ fdZ xZS ):pytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapperFc                     xj         dz  c_         t                                          |          }xj         dz  c_         |S )NrU   )_recursive_debugsuperdo_debugselfargret	__class__rR   s      r#   rl   zCpytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapper.do_debug   sG    $$)$$gg&&s++$$)$$
r5   c                 T   t                                          |          }j        dk    rĉj        J j                            j                  }|                                 | j        }t          	                    |          }|rO|dk    r|
                    dd           n|
                    dd|z             |J |                                 n|
                    dd           j        J j        j                            j        |            d| _        |S )	Nr   global>z#PDB continue (IO-capturing resumed)z*PDB continue (IO-capturing resumed for %s)zPDB continuer6   rB   T)rk   do_continuerj   rA   r6   create_terminal_writerline_pytest_capmanr<   rS   sepresumer@   hookpytest_leave_pdb
_continued)	rn   ro   rp   twrO   	capturingrq   _pytestrR   s	         r#   rv   zFpytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapper.do_continue   s2   gg))#..'1,,;222 >>s{KKBGGIII!0F ) 7 7 ? ?I  4$00FF3(MNNNNFF # L"+!,  
  &111sN333)555"'88QU8VVV"&
r5   c                     t                                          |          }j        dk    rt          j        d           |S )a  Raise Exit outcome when quit command is used in pdb.

                This is a bit of a hack - it would be better if BdbQuit
                could be handled, but this would require to wrap the
                whole pytest run, and adjust the report etc.
                r   Quitting debugger)rk   do_quitrj   r   exitrm   s      r#   r   zBpytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapper.do_quit   s>     ggooc**'1,,M"5666
r5   c                     t                                          ||          }|s)| j        r"| j        r| j                            d           |S )zSuspend on setup().

                Needed after do_continue resumed, and entering another
                breakpoint again.
                Tin_)rk   setupr~   ry   suspend_global_capture)rn   ftbrp   rq   s       r#   r   z@pytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapper.setup   s\     ggmmAr** Mt M * M+BBtBLLL
r5   c                 H   t                                          ||          \  }}|wt          dt          |          dz
            }|rU||         d         j                            dd          r.|dz  }|r'||         d         j                            dd          .||fS )Nr   rU   __tracebackhide__F)rk   	get_stackmaxlenf_localsget)rn   r   tstackirq   s        r#   r   zDpytestPDB._get_pdb_wrapper_class.<locals>.PytestPdbWrapper.get_stack   s     77,,Q22q9As5zzA~..A a 4 8 89Le T T Q  a 4 8 89Le T T axr5   )__name__
__module____qualname__ry   r~   rl   rv   do_cdo_contr   do_qdo_exitr   r   __classcell__)rq   r   rO   rR   s   @r#   PytestPdbWrapperrh      s        #NJ           6 )(D7      DG                     r5   r   )_pytest.config)rR   ra   rO   r   r   s   ` ` @r#   r^   z pytestPDB._get_pdb_wrapper_class   sd    M	  M	  M	  M	  M	  M	  M	  M	  M	 w M	  M	  M	 ^  r5   c                    ddl }| j        d}n| j                            d          }|r|                    d           | j        r|j                            | j                  }|                                 | j        dk    r|	                    dd          }||
                    d|           no|                     |          }|dk    r|
                    dd	| d
           n9|r|
                    dd	|d|d           n|
                    dd	|             |                     |          di |}	| j        r&| j        j                            | j        |	           |	S )z4Initialize PDB debugging, dropping any IO capturing.r   NcapturemanagerTr   headerrt   rs   zPDB z (IO-capturing turned off)z (IO-capturing turned off for )ru    )r   r@   	getpluginsuspendrA   r6   rw   rx   rj   r>   rz   rS   re   r|   pytest_enter_pdb)
rR   methodargskwargsr   rO   r   r   r   _pdbs
             r#   	_init_pdbzpytestPDB._init_pdb   s    	%/3FF'112BCCF 	%NNtN$$$; 	566s{CCBGGIII#q((Hd33%FF3'''' # 1 1& 9 9I H,,s$M6$M$M$MNNNN" 5C%vvyyy2    sO6OO444*s""6**44V44 	S#44CKT4RRRr5   c                     t          j                    j        } | j        dg|R i |}|                    |           dS )zBInvoke debugging via ``Pdb.set_trace``, dropping any IO capturing.r?   N)rY   	_getframef_backr   r?   )rR   r   r   framer   s        r#   r?   zpytestPDB.set_trace  sK     &s}[:4:::6::ur5   rD   )r   r   r   __doc__r@   r   r   __annotations__rA   r   r=   r   r   r   rj   rN   r	   r   classmethodr   strboolrS   re   r^   r   r?   r   r5   r#   r<   r<   _   s        1148NH01888 $GXf$$$ 	 Dhy!8,?#@(6BRRS    >BhuT#YS	%9:;BBB8,<#= %T	BR    [
 $X.>%? $ $ $ [$L T X>N5O T  T  T  [T l % % [%N    [  r5   r<   c                   B    e Zd ZdedddeddfdZdee         ddfd	ZdS )
rI   nodecallzCallInfo[Any]reportr   Nc                    |j         j                            d          }|rk|                    d           |                                \  }}t
          j                            |           t
          j                            |           |j        J t          |j        j
        t          j                  st          ||j        |           d S d S )Nr   Tr   )r6   rF   r   r   read_global_capturerY   stdoutwriteexcinfo
isinstancer   unittestSkipTest
_enter_pdb)rn   r   r   r   rO   outerrs          r#   pytest_exception_interactz#PdbInvoke.pytest_exception_interact  s     *445EFF 	"))d)3331133HCJS!!!JS!!!|'''$,,h.?@@ 	3tT\622222	3 	3r5   r   c                 B    t          |          }t          |           d S r;   )_postmortem_tracebackpost_mortem)rn   r   r   s      r#   pytest_internalerrorzPdbInvoke.pytest_internalerror-  s    "7++Br5   )	r   r   r   r   r   r   r   BaseExceptionr   r   r5   r#   rI   rI     so        33 /39C3	3 3 3 3M-,H T      r5   rI   c                   J    e Zd Z ed          ded         fd            ZdS )rH   T)hookwrapperr   )NNNc              #   0   K   t          |           d V  d S r;   ) wrap_pytest_function_for_tracing)rn   
pyfuncitems     r#   pytest_pyfunc_callzPdbTrace.pytest_pyfunc_call3  s!      (444r5   N)r   r   r   r   r   r   r   r5   r#   rH   rH   2  sM        X$	:J0K       r5   rH   c                     t                               d          | j        t          j                  fd            }|| _        dS )zChange the Python function object of the given Function item by a
    wrapper which actually enters pdb before calling the python function
    itself, effectively leaving the user in the pdb prompt in the first
    statement of the function.runcallc                  \    t          j        g| R i |}                    |           d S r;   )	functoolspartialr   )r   r   funcr   testfunctions      r#   wrapperz1wrap_pytest_function_for_tracing.<locals>.wrapperD  s;     ??????Tr5   N)r<   r   objr   wraps)r   r   r   r   s     @@r#   r   r   9  sb    
 y))D>L
 _\""     #" JNNNr5   c                 \    | j                             d          rt          |            dS dS )zaWrap the given pytestfunct item for tracing support if --trace was given in
    the command line.r0   N)r6   rE   r   )r   s    r#   &maybe_wrap_pytest_function_for_tracingr   L  s;     !!'** 5(444445 5r5   r   r   repc                 @   | j         j                            d          j        }|                                 | j         j        j        }d|j        fd|j        fd|j	        ffD ]S\  }}||dfv rH|rF|
                    dd|z              |dd          d	k    r
|d d         }|                    |           T|
                    dd
           |                    |           |
                    dd           t          |          }d|_        t          |           |S )Nterminalreporterr   stderrlogallrt   z	captured 
	tracebackzentering PDBT)r6   rF   r   _twrx   optionshowcapture	capstdout	capstderrcaplogrz   
toterminalr   	_pdbshownr   )r   r   r   r   r   sectionnamecontentr   s           r#   r   r   S  s1    
	"	,	,-?	@	@	DBGGIII+$0K 
3=!	3=!	
! 	 	W
 ;...7.FF3k1222rss|t##!#2#,GGGFF3NN2FF3	w	'	'BCMOOOJr5   c                     ddl m} t          | j        |          r| j        j        d         S t          | j        t
                    r| j        j        d         S | j        J | j        d         S )Nr   )UnexpectedException   )doctestr   r   r   exc_infor   r   _excinfo)r   r   s     r#   r   r   r  s    ++++++'-!455 
# }%a((	GM#8	9	9 # }$Q''+++""r5   r   c                     t                               d          }|                                 |                    d |            |j        rt          j        d           d S d S )Nr   r   )r<   r   resetinteractionquittingr   r   )r   ps     r#   r   r     sa    M**AGGIIIMM$z +)*****+ +r5   )3r   r   r   rY   typesr   typingr   r   r   r   r   r   r	   r
   r   r   r   _pytest._coder   r   r   r   r   r   _pytest.config.argparsingr   _pytest.config.exceptionsr   _pytest.nodesr   _pytest.reportsr   _pytest.capturer   _pytest.runnerr   r   r$   r4   rL   r<   rI   rH   r   r   r   r   TracebackTyper   r   r   r5   r#   <module>r     s\   : :      



                                                                     ' ' ' ' ' ' ! ! ! ! ! ! 0 0 0 0 0 0 # # # # # # . . . . . . , , , , , , 0 0 0 0 0 0       & & & & & & (......''''''   c3h        V     0V     6| | | | | | | |~       (         &5 5 5
&}5<F   >#=#? #EDW # # # # +5& +4 + + + + + +r5   