HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_bdb.cpython-37.opt-1.pyc
B

��gפ�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
ddlZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZdZd
d�Zdd�ZGdd�dej�ZGdd�de�ZGdd�d�Zd5dd�Ze
dd��Zeddfdd�ZdZedZ d d!�Z!d"d#�Z"d$d%�Z#d&d'�Z$Gd(d)�d)ej%�Z&Gd*d+�d+e&�Z'Gd,d-�d-e&�Z(Gd.d/�d/e&�Z)Gd0d1�d1e&�Z*d2d3�Z+e,d4k�r�e+�dS)6a� Test the bdb module.

    A test defines a list of tuples that may be seen as paired tuples, each
    pair being defined by 'expect_tuple, set_tuple' as follows:

        ([event, [lineno[, co_name[, eargs]]]]), (set_type, [sargs])

    * 'expect_tuple' describes the expected current state of the Bdb instance.
      It may be the empty tuple and no check is done in that case.
    * 'set_tuple' defines the set_*() method to be invoked when the Bdb
      instance reaches this state.

    Example of an 'expect_tuple, set_tuple' pair:

        ('line', 2, 'tfunc_main'), ('step', )

    Definitions of the members of the 'expect_tuple':
        event:
            Name of the trace event. The set methods that do not give back
            control to the tracer [1] do not trigger a tracer event and in
            that case the next 'event' may be 'None' by convention, its value
            is not checked.
            [1] Methods that trigger a trace event are set_step(), set_next(),
            set_return(), set_until() and set_continue().
        lineno:
            Line number. Line numbers are relative to the start of the
            function when tracing a function in the test_bdb module (i.e. this
            module).
        co_name:
            Name of the function being currently traced.
        eargs:
            A tuple:
            * On an 'exception' event the tuple holds a class object, the
              current exception must be an instance of this class.
            * On a 'line' event, the tuple holds a dictionary and a list. The
              dictionary maps each breakpoint number that has been hit on this
              line to its hits count. The list holds the list of breakpoint
              number temporaries that are being deleted.

    Definitions of the members of the 'set_tuple':
        set_type:
            The type of the set method to be invoked. This may
            be the type of one of the Bdb set methods: 'step', 'next',
            'until', 'return', 'continue', 'break', 'quit', or the type of one
            of the set methods added by test_bdb.Bdb: 'ignore', 'enable',
            'disable', 'clear', 'up', 'down'.
        sargs:
            The arguments of the set method if any, packed in a tuple.
�N)�contextmanager)�islice�repeatc@seZdZdS)�BdbExceptionN)�__name__�
__module__�__qualname__�r	r	�)/usr/local/lib/python3.7/test/test_bdb.pyr>src@seZdZdZdS)�BdbErrorz!Error raised by the Bdb instance.N)rrr�__doc__r	r	r	r
r?src@seZdZdZdS)�BdbSyntaxErrorzSyntax error in the test case.N)rrrrr	r	r	r
r
@sr
c@seZdZdZdS)�BdbNotExpectedErrorzUnexpected result.N)rrrrr	r	r	r
rAsrcCsdtj_itj_dgtj_dS)N�)�_bdb�
Breakpoint�nextZbplist�
bpbynumberr	r	r	r
�reset_BreakpointIsrcCs�dd�tjjD�}|sdSd}x~|D]v}|s4d}d}|jr>dnd}|jrLd	nd
}|d|j|||j|jtj	�
|j�|jf7}|j
r�|d|j
f7}|d
7}q$W|S)NcSsg|]}|r|�qSr	r	)�.0�bpr	r	r
�
<listcomp>Osz$info_breakpoints.<locals>.<listcomp>�Fz!BpNum Temp Enb Hits Ignore Where
Tzyes zno  Zyeszno z%-5d %s %s %-4d %-6d at %s:%dz
	stop only if %s�
)rrr�	temporary�enabledZnumber�hits�ignore�os�path�basename�file�line�cond)�bp_listZheader_addedr�infoZdispZenabr	r	r
�info_breakpointsNs"
r&csjeZdZdZ�fdd�Zd�fdd�	Z�fdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�Z
S)�Bdbz$Extend Bdb to enhance test coverage.csd|_t��|||�S)N)�	currentbp�super�trace_dispatch)�self�frame�event�arg)�	__class__r	r
r*fszBdb.trace_dispatchFNcs�t|t�rT|tkrt�}nt�|dd��}|j}t||�}|j}	|	j	}|	j
}|	j}t�j
|||||d�}
t|
t�r|t|
��|
S)N���)rr#�funcname)�
isinstance�str�__file__�globals�	importlib�
import_module�__dict__�eval�__code__�co_filename�co_firstlineno�co_namer)�	set_breakr)r+�filename�linenorr#r1�globals_�module�func�code�res)r/r	r
r>js



z
Bdb.set_breakcs4t��||�\|_|_|j|jd|_|j|jfS)Nr)r)�	get_stack�stack�indexr,)r+�f�t)r/r	r
rF~sz
Bdb.get_stackcCs|�|�}|jd7_dS)z8Increment the ignore count of Breakpoint number 'bpnum'.rN)�get_bpbynumberr)r+�bpnumrr	r	r
�
set_ignore�s
zBdb.set_ignorecCs|�|�}d|_dS)NT)rKr)r+rLrr	r	r
�
set_enable�s
zBdb.set_enablecCs|�|�}d|_dS)NF)rKr)r+rLrr	r	r
�set_disable�s
zBdb.set_disablecCs|�||�}|rt|��dS)N)Zclear_breakr)r+�fnamer@�errr	r	r
�	set_clear�sz
Bdb.set_clearcCs2|jstd��|jd8_|j|jd|_dS)zMove up in the frame stack.zOldest framerrN)rHrrGr,)r+r	r	r
�set_up�sz
Bdb.set_upcCs@|jdt|j�krtd��|jd7_|j|jd|_dS)zMove down in the frame stack.rzNewest framerN)rH�lenrGrr,)r+r	r	r
�set_down�szBdb.set_down)FNN)rrrrr*r>rFrMrNrOrRrSrU�
__classcell__r	r	)r/r
r'csr'cs�eZdZdZd,�fdd�	Zdd�Z�fdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd-d&d'�Zd(d)�Zd*d+�Z�ZS).�Tracerz$A tracer for testing the bdb module.NFcs<t�j|d�||_||_|dk	r*d|nd|_|��dS)N)�skipzDry-run results for %s:)r)�__init__�
expect_set�dry_run�header�	init_test)r+rZrXr[�	test_case)r/r	r
rY�s
zTracer.__init__cCsBd|_d|_d|_tt|jddd��|_tt|jddd��|_dS)Nr�r)�
cur_except�
expect_set_no�breakpoint_hits�listrrZ�
expected_list�set_list)r+r	r	r
r]�s
zTracer.init_testc
sn|jdk	r|j�|dkrZyt��|||�}|Stk
rV}z||_|jSd}~XYqjXnt��|||�SdS)N�	exception)r`r)r*r)r+r,r-r.rE�e)r/r	r
r*�s
zTracer.trace_dispatchcCs(|�|�sdS|�d||�|��dS)N�call)Z	stop_here�
process_event�next_set_method)r+r,Z
argument_listr	r	r
�	user_call�s
zTracer.user_callcCs^|�d|�|jrD|jrDt��d�}x|�d�D]}td|�q0W|��d|_|��dS)Nr"rz  )	rir[rbr&�strip�split�print�delete_temporariesrj)r+r,r%r"r	r	r
�	user_line�szTracer.user_linecCs|�d||�|��dS)N�return)rirj)r+r,Zreturn_valuer	r	r
�user_return�szTracer.user_returncCs||_|�d|�|��dS)Nrf)�exc_inforirj)r+r,rsr	r	r
�user_exception�szTracer.user_exceptioncCs|jg}||f|_dS)N)r(rb)r+r.r$r	r	r
�do_clear�szTracer.do_clearcCs(|jr$x|jdD]}|�|�qWdS)Nr)rbZclear_bpbynumber)r+�nr	r	r
ro�szTracer.delete_temporariescCsV|jd7_y|j�d�|_Wn"tk
rBtd|j��YnX|j�d�|_dS)Nrrz-expect_set list exhausted, cannot pop item %d)rard�pop�expect�
IndexErrorrre�	set_tuple)r+r	r	r
�pop_next�szTracer.pop_nextcs�d}|dkr�jd}��||��jdk	rD�jsD�jg}|gf�_|�_����jrh���j�dS�j	r���
�j	d|d����|dkr���d�n�t
�j	�dk�r~|dk�rF�j	d\�}t����}�js��d�j���
|�jdd	���
�fd
d�|D��fdd��jdD�d
���
t|��jdd�n8|dk�r~t�jd�j	d��s~��d�j�jf�dS)Nrfr_rzWrong event type)rhrq�r"z(No breakpoints hit at expect_set item %dzBreakpoint numbers do not matchcsg|]}�|�qSr	r	)rrv)�bpsr	r
rsz(Tracer.process_event.<locals>.<listcomp>csg|]}��|�j�qSr	)rKr)rrv)r+r	r
r szWrong breakpoint hit countrzWrong temporary breakpointsz/Wrong exception at expect_set item %d, got '%s')rsrFr(rbr-r{r[�print_stater\rx�check_equal�check_lno_name�check_expect_max_sizerT�sorted�keys�raise_not_expectedrar2)r+r-r,�args�tbr$ZtemporariesZbpnumsr	)r}r+r
ri�sL





zTracer.process_eventcCs&||krdS|�d||j|f�dS)Nz"%s at expect_set item %d, got '%s')r�ra)r+Zexpected�result�msgr	r	r
r,szTracer.check_equalcCsTt|j�}|dkr.|��}|�|jd|d�|dkrP|�|jd|jjjd�dS)z+Check the line number and function co_name.rzWrong line numberr_zWrong function nameN)rTrx�lno_abs2relrr,�f_coder=)r+�sr@r	r	r
r�2s
zTracer.check_lno_namecCs&t|j�|kr"td|j|jf��dS)Nz'Invalid size of the %s expect tuple: %s)rTrxr
r-)r+�sizer	r	r
r�<szTracer.check_expect_max_sizecCs<|�|jjj�}|jj}||�t�kr8||jjjdS|S)Nr)�canonicr,r�r;�f_linenor4r<)r+rPr@r	r	r
r�AszTracer.lno_abs2relcCs.|r*|�|�|�t�kr*|jjj|dS|S)Nr)r�r4r,r�r<)r+rPr@r	r	r
�lno_rel2absGs*zTracer.lno_rel2abscCs�|��}|jjj}d|j||f}|jr�d}x:|jdD],}|dkrL|d7}|d||�|�jf7}q8W|d7}d|dt|jd�d	}|d|7}n|jd
kr�|d|j	dj
7}|d7}|�d�t|j�d
S)Nz('%s', %d, '%s'�{rz, z%s: %s�}�(r�)rfz), � �,)
r�r,r�r=r-rbrKrr3rsr�ljustrz)r+r@r=�stater}rvr	r	r
�	get_stateLs 

zTracer.get_statecCs:|dk	r |jdkr t�t|�td|j|��f�dS)Nrz%d: %s)rarnr�)r+r\r	r	r
r~^szTracer.print_statecCs6|d7}|dt|j�7}|d|��7}t|��dS)Nrz  Expected: %s
z  Got:      )r3rxr�r)r+r�r	r	r
r�dszTracer.raise_not_expectedcCsZ|jd}t|j�dkr"|jdnd}t|d|�}|dkrF|�dS|dkr\||j�dS|dkr�d}|r�|�|jjj|d�}||j|�dS|r�|dks�|d	k�rH|d
kr�|^}}}|�||�}||g}|�|�||�n"|dkr�||�n|d	k�r|�d|_|�	�|j
�r$|��n|j�r4|�
�|�d�|��ntd
|j��dS)Nrr_rZset_)�step�continue�quit)rrq�until)�break�clearr�enable�disable)�up�down)r�r�)rr�r�r|z"%s" is an invalid set_tuple)rzrT�getattrr,r�r�r;�extendr-r{r[r~rxr�r�rjr
)r+�set_typer�Z
set_methodr@rPZremainr	r	r
rjjsL











zTracer.next_set_method)NFN)N)rrrrrYr]r*rkrprrrtruror{rirr�r�r�r�r�r~r�rjrVr	r	)r/r
rW�s*	

2

rWc@s,eZdZdZd	dd�Zdd�Zd
dd�ZdS)�	TracerRunzAProvide a context for running a Tracer instance with a test case.NcCs2||_|j|_t|j||j|��d�|_d|_dS)N)rXr[r^)r^r[rWrZ�id�tracer�_original_tracer)r+r^rXr	r	r
rY�s
zTracerRun.__init__cCst�t��|_|jS)N)r�sys�gettracer�r�)r+r	r	r
�	__enter__�s
zTracerRun.__enter__cCs�t�t�|j�d}|jjr6|d7}|d|jj7}|dk	r�tt|�r�t	|t
�r�|jr�|jd}|rr|d|7}|jr�t
|�dS|j�|�n|r�|jr�t
|�n|j�|�dS)Nrz+All paired tuples have not been processed, zthe last one was number %drrT)rr��settracer�r�rera�
issubclassrr2�
BaseExceptionr�r[rnr^�fail)r+Ztype_�value�	tracebackZ	not_emptyZerr_msgr	r	r
�__exit__�s(

zTracerRun.__exit__)N)NNN)rrrrrYr�r�r	r	r	r
r��s
r�c
Cs�dd�}ddg}|�|�t�}d|_dd�|_t|td�t|���|_t|��(t	||d	��}|�
t�Wd
QRXWd
QRXd
S)a{Run a test and print the dry-run results.

    'modules':  A dictionary mapping module names to their source code as a
                string. The dictionary MUST include one module named
                'test_module' with a main() function.
    'set_list': A list of set_type tuples to be run on the module.

    For example, running the following script outputs the following results:

    *****************************   SCRIPT   ********************************

    from test.test_bdb import run_test, break_in_func

    code = '''
        def func():
            lno = 3

        def main():
            func()
            lno = 7
    '''

    set_list = [
                break_in_func('func', 'test_module.py'),
                ('continue', ),
                ('step', ),
                ('step', ),
                ('step', ),
                ('quit', ),
            ]

    modules = { 'test_module': code }
    run_test(modules, set_list)

    ****************************   results   ********************************

    1: ('line', 2, 'tfunc_import'),    ('next',),
    2: ('line', 3, 'tfunc_import'),    ('step',),
    3: ('call', 5, 'main'),            ('break', ('test_module.py', None, False, None, 'func')),
    4: ('None', 5, 'main'),            ('continue',),
    5: ('line', 3, 'func', ({1: 1}, [])), ('step',),
      BpNum Temp Enb Hits Ignore Where
      1     no   yes 1    0      at test_module.py:2
    6: ('return', 3, 'func'),          ('step',),
    7: ('line', 7, 'main'),            ('step',),
    8: ('return', 7, 'main'),          ('quit',),

    *************************************************************************

    css@y&x t|�}t|�}|V|VqWWntk
r:dSXdS)N)r�
StopIteration)�a�b�x�yr	r	r
�gen�szrun_test.<locals>.gen)r)r�TcSsdS)Nr	r	r	r	r
�<lambda>�zrun_test.<locals>.<lambda>r	)rXN)r��BaseTestCaser[r�rcr�iterrZ�create_modulesr��runcall�tfunc_import)�modulesrerXr��sl�testr�r	r	r
�run_test�s3


r�ccs�tj����tj�t���z\xH|D]@}|d}t|d��}|�	t
�||��WdQRXt�
|�q$Wt��dVWdx|D]}tj�|�q�Wtj��XWdQRXdS)Nz.py�w)r��supportZtemp_cwdr�r�appendr�getcwd�open�write�textwrap�dedent�	linecache�
checkcacher6�invalidate_cachesZforgetrw)r��mrPrIr	r	r
r�s


r�FcCsd|d|||ffS)Nr�r	)r1rPrr#r	r	r
�
break_in_func%sr��test_module_for_bdbz.pycCsddl}|��dS)Nr)r��main)r�r	r	r
r�*sr�cCs d}t�t�d}d}d}dS)Nr_���)�tfunc_first�tfunc_second)�lnor	r	r
�
tfunc_main.sr�cCsd}d}d}dS)Nr_r|�r	)r�r	r	r
r�6sr�cCsd}dS)Nr_r	)r�r	r	r
r�;sr�c@seZdZdZeZddd�ZdS)r�zBase class for all tests.NcCs|�|�d�dS)N)ZfailureException)r+r�r	r	r
r�CszBaseTestCase.fail)N)rrrrr[r�r	r	r	r
r�>sr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�
StateTestCasez;Test the step, next, return, until and quit 'set_' methods.c	Cs8ddddddddg|_t|��}|�t�WdQRXdS)N)r"r_r�)r�)r"r|r�)rhrr�)r"r_r�)r�)rZr�r�r�)r+r�r	r	r
�	test_stepKs

zStateTestCase.test_stepcCs�xzdD]r}|j|d��\ddddddtdffd	d
dddd
d
igff|fddg|_t|��}|�t�WdQRXWdQRXqWdS)N)r�r)r�)r"r_r�)r�)r"r|r�)rhrr�r�r|)�Nonerr�)r�r"r�r)r"r�r�)r�)�subTestr4rZr�r�r�)r+r�r�r	r	r
� test_step_next_on_last_statementUs


z.StateTestCase.test_step_next_on_last_statementc
Cs<ddddddddddg
|_t|��}|�t�WdQRXdS)	N)r"r_r�)r�)r"r|r�)r)r"r�r�)rhrr�)r"r_r�)r�)rZr�r�r�)r+r�r	r	r
�	test_nextcs

zStateTestCase.test_nextc
CsPd}t|i}t|��2ddddg|_t|��}|�t�WdQRXWdQRXdS)Nz9
            def main():
                lno = 3
        )r"r_r�)r)r"r|r�)r�)�TEST_MODULEr�rZr�r�r�)r+rDr�r�r	r	r
�test_next_over_importns


z#StateTestCase.test_next_over_importc	Cs8ddddddddg|_t|��}|�t�WdQRXdS)N)r"r_r�)r�)r"r|r�)rhrr�)r)r"r_r�)r�)rZr�r�r�)r+r�r	r	r
�test_next_on_plain_statement|s

z*StateTestCase.test_next_on_plain_statementc
Cs<dddddddddd	g
|_t|��}|�t�WdQRXdS)
N)r"r_r�)r�)r"r|r�)rhrr�)r�)r�r|r�)r)r"r�r�)r�)rZr�r�r�)r+r�r	r	r
�test_next_in_caller_frame�s

z'StateTestCase.test_next_in_caller_framecCs@dddddddddddd	g|_t|��}|�t�WdQRXdS)
N)r"r_r�)r�)r"r|r�)rhrr�)r"r_r�)rq)rqr�r�)r"r�r�)r�)rZr�r�r�)r+r�r	r	r
�test_return�s

zStateTestCase.test_returnc
Cs<dddddddddd	g
|_t|��}|�t�WdQRXdS)
N)r"r_r�)r�)r"r|r�)rhrr�)r�)r�r|r�)rq)rqr�r�)r�)rZr�r�r�)r+r�r	r	r
�test_return_in_caller_frame�s

z)StateTestCase.test_return_in_caller_framec
Cs<ddddddddddg
|_t|��}|�t�WdQRXdS)	N)r"r_r�)r�)r"r|r�)rhrr�)r"r_r�)r�)r�)r"r�r�)r�)rZr�r�r�)r+r�r	r	r
�
test_until�s

zStateTestCase.test_untilc	CsLdtd�dddddddigffdd	d
g|_t|��}|�t�WdQRXdS)N)r"r_r�r�)r�r_r�)r�r"r_r)r�)i')rqr�r�)r�)r�rZr�r�r�)r+r�r	r	r
�test_until_with_too_large_count�s

z-StateTestCase.test_until_with_too_large_countc
Cs<dddddddddd	g
|_t|��}|�t�WdQRXdS)
N)r"r_r�)r�)r"r|r�)rhrr�)r�)r�r|r�)r�)r�)r"r�r�)r�)rZr�r�r�)r+r�r	r	r
�test_until_in_caller_frame�s

z(StateTestCase.test_until_in_caller_framec
Cs\d}t|i}t|��>ddddg|_dtf}t||d��}|�t�WdQRXWdQRXdS)Nz9
            def main():
                lno = 3
        )r"r_r�)r�)r"r|r�)r�z
importlib*)rX)r�r�rZr�r�r�)r+rDr�rXr�r	r	r
�	test_skip�s

zStateTestCase.test_skipc	Cs2ddg|_t|��}|�t|jt�WdQRXdS)N)r"r_r�)r�)rZr��assertRaisesrr�r�)r+r�r	r	r
�	test_down�s

zStateTestCase.test_downc	Cs8ddddddddg|_t|��}|�t�WdQRXdS)N)r"r_r�)r�)r"r|r�)rhrr�)r�)r�r|r�)r�)rZr�r�r�)r+r�r	r	r
�test_up�s

zStateTestCase.test_upN)rrrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r	r	r
r�Hs


r�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BreakpointTestCasezTest the breakpoint set method.c	Cs2ddg|_t|��}|�t|jt�WdQRXdS)N)r"r_r�)r�)z/non/existent/module.pyr)rZr�r�rr�r�)r+r�r	r	r
�test_bp_on_non_existent_module�s

z1BreakpointTestCase.test_bp_on_non_existent_modulec
CsZd}t|i}t|��<ddtdffg|_t|��}|�t|jt�WdQRXWdQRXdS)Nz9
            def main():
                lno = 3
        )r"r_r�r�r�)	r�r��TEST_MODULE_FNAMErZr�r�rr�r�)r+rDr�r�r	r	r
�test_bp_after_last_statement�s

z/BreakpointTestCase.test_bp_after_last_statementcCs�d}t|i}t|��rdtdtd�dtdtd�dddddd	d	id	gffddddd
d	id
gffdg
|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func():
                lno = 3

            def main():
                for i in range(2):
                    func()
        )r"r_r�rCT)r�r_r�)r�r"r|rr_)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�test_temporary_bps



z$BreakpointTestCase.test_temporary_bpcCs�d}t|i}t|���dtdt�dtdtd�dddddd	dd
d
igffddd
dddd	ddd
idgffddddd	dd
digffdg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func():
                lno = 3

            def main():
                for i in range(3):
                    func()
        )r"r_r�rC)r�r_r�T)r�)r_)r�r"r|r)r�)r_)r�r|rC)r�)rr_)r�)r)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�test_disabled_temporary_bps"


z-BreakpointTestCase.test_disabled_temporary_bpc
Csnd}t|i}t|��Pdtdtdd�dddd	dd
d	igffdg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func(a):
                lno = 3

            def main():
                for i in range(3):
                    func(i)
        )r"r_r�rCFza == 2)r�r_r�)r�r"r|r)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�test_bp_condition9s

z$BreakpointTestCase.test_bp_conditionc
Csnd}t|i}t|��Pdtdtdd�dddd	dd
d
igffdg|_t|��}|�t�WdQRXWdQRXdS)Nzk
            def func(a):
                lno = 3

            def main():
                func(0)
        )r"r_r�rCFz1 / 0)r�r_r�)r�r"r|r)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�)test_bp_exception_on_condition_evaluationMs

z<BreakpointTestCase.test_bp_exception_on_condition_evaluationcCsnd}t|i}t|��Pdtdt�dddddddd	d
igffdg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func():
                lno = 3

            def main():
                for i in range(2):
                    func()
        )r"r_r�rC)r�r_r�)r)r)r�r"r|rr_)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�test_bp_ignore_count`s

z'BreakpointTestCase.test_bp_ignore_countcCs�d}t|i}t|���dtdt�dtdt�dddddddd	dd
digffdd
ddd	dd
d
igffddd	ddd
igffdg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func():
                lno = 3

            def main():
                for i in range(3):
                    func()
        )r"r_r�rC)r�r_r�)r)r)r�)r)r�r"r|r_r)r�)r)r�r|rC)r�)r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
� test_ignore_count_on_disabled_bpus 

z3BreakpointTestCase.test_ignore_count_on_disabled_bpcCs�d}t|i}t|���ddtdffddtdffddtdffddddd	d
d
igffdddd	dd
igffdtdffddddd	dd
igffdg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def func():
                lno = 3
                lno = 4

            def main():
                for i in range(3):
                    func()
        )r"r_r�r�r|)r�r_r�r�)r�r"rCrr�)r�r�rCr_)r�)r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�test_clear_two_bp_on_same_line�s	

z1BreakpointTestCase.test_clear_two_bp_on_same_linec	Cs:ddtdffg|_t|��}|�t|jt�WdQRXdS)N)r"r_r�r�r)r4rZr�r�rr�r�)r+r�r	r	r
�test_clear_at_no_bp�s
z&BreakpointTestCase.test_clear_at_no_bpN)rrrrr�r�r�r�r�r�r�r�r�r�r	r	r	r
r��s
r�c@s eZdZdZdd�Zdd�ZdS)�RunTestCasez Test run, runeval and set_trace.c	CsBd}ddddg|_t|��}|�tt�|�dd��WdQRXdS)Nz
            lno = 2
        )r"r_z<module>)r�)rqr_z<module>)r�z<string>�exec)rZr��run�compiler�r�)r+rDr�r	r	r
�
test_run_step�s


zRunTestCase.test_run_stepcCsld}t|i}t|��Nddddddddddg
|_d	dl}t|��}|�d
t�t��WdQRXWdQRXdS)Nz9
            def main():
                lno = 3
        )r"rz<module>)r�)rhr_r�)r"r|r�)rqr|r�)rqrz<module>)r�rztest_module_for_bdb.main())r�r�rZr�r�Zrunevalr5�locals)r+rDr�r�r�r	r	r
�test_runeval_step�s


zRunTestCase.test_runeval_stepN)rrrrr�rr	r	r	r
r��sr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�IssuesTestCasezTest fixed bdb issues.cCszd}d}t|d|i}t|��Tdtdd�ddd	d
dddigffdd
dddg
|_t|��}|�t�WdQRXWdQRXdS)Nz�
            from test_module_for_bdb_2 import func
            def main():
                func()
                lno = 5
        z9
            def func():
                lno = 3
        Ztest_module_for_bdb_2)r"r_r�rCztest_module_for_bdb_2.py)r�r_r�)r�r"r|r)r�)rqr|rC)r"r�r�)r�)r�r�r�rZr�r�r�)r+Zcode_1Zcode_2r�r�r	r	r
�+test_step_at_return_with_no_trace_in_caller�s	


z:IssuesTestCase.test_step_at_return_with_no_trace_in_callercCs�d}t|i}x�dD]�}|j|d���t|���dtdt�dddd	dd
d
igff|fg|_|dkr~|j�dd
dtfdddg�n|j�ddg�t|��}|�	t
�WdQRXWdQRXWdQRXqWdS)Nz�
            def test_gen():
                yield 0
                lno = 4
                return 123

            def main():
                it = test_gen()
                next(it)
                next(it)
                lno = 11
        )rr�rq)r�)r"r_r��test_gen)r�r_r�)r�r"r|rrqrf�
r�)r�)rqrr�)r�)r"r�r)r�r�r�r�r�rZr�r�r�r�r�)r+rDr�r�r�r	r	r
�#test_next_until_return_in_generator�s"



z2IssuesTestCase.test_next_until_return_in_generatorcCs�d}t|i}t|��hdtdt�dddddddigffd	d
d	dd	dd	d
ddtfdddg|_t|��}|�t�WdQRXWdQRXdS)Nz�
            def test_gen():
                yield 0
                lno = 4
                yield 1
                return 123

            def main():
                for i in test_gen():
                    lno = 10
                lno = 11
        )r"r_r�r)r�r_r�)r�r"r|r)r)r"r�r)r"r�r)r"r�rrf�	r�)r�)r"�r�)r�)	r�r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�'test_next_command_in_generator_for_loops



z6IssuesTestCase.test_next_command_in_generator_for_loopc
Cs~d}t|i}t|��`dtdt�dddddddigffd	d
d	ddd
tfdddg|_t|��}|�t�WdQRXWdQRXdS)Na4
            def test_subgen():
                yield 0
                return 123

            def test_gen():
                x = yield from test_subgen()
                return 456

            def main():
                for i in test_gen():
                    lno = 12
                lno = 13
        )r"r_r�r)r�r_r�)r�r"r�r)r)r"�rrfrr�)r�)r"�
r�)r�)	r�r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�/test_next_command_in_generator_with_subiterator;s


z>IssuesTestCase.test_next_command_in_generator_with_subiteratorc
Cs�d}t|i}t|��hdtdt�dddddddigffd	d
ddtfd	d
d
dtfdddg|_t|��}|�t�WdQRXWdQRXdS)Na4
            def test_subgen():
                yield 0
                return 123

            def test_gen():
                x = yield from test_subgen()
                return 456

            def main():
                for i in test_gen():
                    lno = 12
                lno = 13
        )r"r_r�Ztest_subgen)r�r_r�)r�r"r|r)rqrfr�rrr�)r�)r"rr�)r�)	r�r�r�r�r�rZr�r�r�)r+rDr�r�r	r	r
�1test_return_command_in_generator_with_subiteratorZs


z@IssuesTestCase.test_return_command_in_generator_with_subiteratorN)	rrrrrrr	rr
r	r	r	r
r�s)rcCstj�tttt�dS)N)r�r�Zrun_unittestr�r�r�rr	r	r	r
�	test_mainys
r�__main__)N)-rZbdbrr�rZunittestr�r6r��
contextlibr�	itertoolsrrZtest.supportr��	Exceptionrrr
rr[rr&r'rWr�r�r�r4r�r�r�r�r�r�r�ZTestCaser�r�r�r�rrrr	r	r	r
�<module>1sR@z.
J
(B"(