Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_pdb.cpython-39.opt-2.pyc

a

��g7��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZddl
mZddlmZddlmZddlmZddlmZdd	�ZGd
d�de�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#e�$d �Z%e&d!e%j'�d"d#�Z(d$d%�Z)d&d'�Z*d(d)�Z+d*d+�Z,d,d-�Z-d.d/�Z.d0d1�Z/d2d3�Z0d4d5�Z1d6d7�Z2d8d9�Z3d:d;�Z4d<d=�Z5d>d?�Z6d@dA�Z7dBdC�Z8GdDdE�dEej9�Z:GdFdG�dGej9�Z;dHdI�Z<e=dJk�r�e�>�dS)K�N)�	ExitStack�redirect_stdout)�StringIO)�support)�
_FakeInput)�patch)�
BreakpointcCsdt_it_dgt_dS)N�)r�nextZbplistZ
bpbynumber�rr�)/usr/local/lib/python3.9/test/test_pdb.py�reset_Breakpointsr
c@s$eZdZdd�Zdd�Zdd�ZdS)�PdbTestInputcCs
||_dS�N)�input)�selfrrrr�__init__ szPdbTestInput.__init__cCs0tj|_t|j�t_ttd�r&t��nd|_dS)N�gettrace)�sys�stdin�
real_stdinrr�hasattrr�
orig_trace�rrrr�	__enter__#szPdbTestInput.__enter__cGs|jt_|jrt�|j�dSr)rrrr�settrace)r�excrrr�__exit__(szPdbTestInput.__exit__N)�__name__�
__module__�__qualname__rrrrrrrrsrcCsdSrrrrrr�test_pdb_displayhook.sr!cCsdSrrrrrr�test_pdb_basic_commandsKsr"cCsdSrrrrrr�test_pdb_breakpoint_commands�sr#cCsdSrrrrrr�test_pdb_pp_repr_excLsr$cCsdSrrrrrr�
do_nothinghsr%cCstd�dS)N�*)�printrrrr�do_somethingksr(cCsdSrrrrrr�test_list_commandsnsr)cCsdSrrrrrr�test_pdb_whatis_command�sr*cCsdSrrrrrr�test_post_mortem�sr+cCsdSrrrrrr�test_pdb_skip_modules5sr,Zmodule_to_skipz6def foo_pony(callback): x = 1; callback(); return NonecCsdSrrrrrr�#test_pdb_skip_modules_with_callbackQsr-cCsdSrrrrrr� test_pdb_continue_in_bottomframe|sr.cCsttjddd�|�|�dS)NTF)ZnosigintZreadrc)�getattr�pdb�Pdb)�method�argrrr�
pdb_invoke�sr4cCsdSrrrrrr�$test_pdb_run_with_incorrect_argument�sr5cCsdSrrrrrr�test_pdb_run_with_code_object�sr6cCsdSrrrrrr�&test_next_until_return_at_return_event�sr7cCsdSrrrrrr�#test_pdb_next_command_for_generatorsr8cCsdSrrrrrr�#test_pdb_next_command_for_coroutineLsr9cCsdSrrrrrr�"test_pdb_next_command_for_asyncgen�sr:cCsdSrrrrrr�%test_pdb_return_command_for_generator�sr;cCsdSrrrrrr�%test_pdb_return_command_for_coroutine�sr<cCsdSrrrrrr�$test_pdb_until_command_for_generator"sr=cCsdSrrrrrr�$test_pdb_until_command_for_coroutineNsr>cCsdSrrrrrr�+test_pdb_next_command_in_generator_for_loop}sr?cCsdSrrrrrr�!test_pdb_next_command_subiterator�sr@cCsdSrrrrrr�test_pdb_issue_20766�srAcCsdSrrrrrr�test_pdb_issue_43318�srBc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!e"j#d?d@��Z$dAdB�Z%dCS)D�PdbTestCasecCst�tj�dSr�r�unlink�TESTFNrrrr�tearDown
szPdbTestCase.tearDowncCs�|�tjd�tjddg|}tj|tjtjtjit	j
�ddi�d��$}|�t�
|��\}}Wd�n1sp0Y|o�t�|�}|o�t�|�}||fS)N�__pycache__�-mr0�PYTHONIOENCODING�utf-8��stdoutr�stderr�env)�
addCleanupr�rmtreer�
executable�
subprocess�Popen�PIPE�STDOUT�os�environ�communicate�str�encode�bytes�decode)rZpdb_args�commands�cmd�procrMrNrrr�_run_pdbs�2zPdbTestCase._run_pdbcCsZd}t|d�� }|�t�|��Wd�n1s40Y|�tj|�|�|g|�S)N�main.py�w)�open�write�textwrap�dedentrPrrEra)r�scriptr^�filename�frrr�run_pdb_scripts
.zPdbTestCase.run_pdb_scriptcCs�d|_t�|j�|jd}|jd}t�|j�t|d��}Wd�n1sR0Yt|d�� }|�t�|��Wd�n1s�0Y|�	tj|j�|�
d|jg|�S)N�t_main�/__main__.py�/__init__.pyrcrI)�module_namerrQrW�mkdirrdrerfrgrPra)rrhr^�	main_file�	init_filerjrrr�run_pdb_module's

.zPdbTestCase.run_pdb_modulecCslttjd��}|�|�Wd�n1s,0Y|s>dn|dtj|df}|�|t�|tj��dS)N�wbrr	)rdrrFre�assertEqualr0Z
find_function)rZfile_content�	func_name�expectedrjrrr�_assert_find_function5s(��z!PdbTestCase._assert_find_functioncCs|�ddd�dS)N�Zfoo)rxrrrr�test_find_function_empty_file>sz)PdbTestCase.test_find_function_empty_filecCs|�d��dd�dS)Nu@def foo():
    pass

def bœr():
    pass

def quux():
    pass
�bœr)r{��rxr[rrrr�test_find_function_foundAs

�z$PdbTestCase.test_find_function_foundcCs|�d�d�dd�dS)NuV# coding: iso-8859-15
def foo():
    pass

def bœr():
    pass

def quux():
    pass
ziso-8859-15r{)r{�r}rrrr�-test_find_function_found_with_encoding_cookieQs
��z9PdbTestCase.test_find_function_found_with_encoding_cookiecCs|�tjd��dd�dS)Nudef bœr():
    pass
r{)r{r	)rx�codecs�BOM_UTF8r[rrrr�!test_find_function_found_with_bombs
�z-PdbTestCase.test_find_function_found_with_bomcCs�ttjd��}|�d�Wd�n1s,0Ytjddtjg}tj|tjtjtj	d�}|�
|jj�|�
d�\}}|�d|d�dS)	Nrtsprint("testing my pdb")
rIr0�rMrrNsquit
sSyntaxErrorz0Got a syntax error running test script under PDB)rdrrFrerrRrSrTrUrVrPrM�closerY�assertNotIn�rrjr_r`rMrNrrr�test_issue7964ls(��zPdbTestCase.test_issue7964cCsHd}d}|�||�\}}|pd|p$d}|�d|d�|�d|d�dS)Nz�
            def do_testcmdwithnodocs(self, arg):
                pass

            import pdb
            pdb.Pdb.do_testcmdwithnodocs = do_testcmdwithnodocs
        zA
            continue
            help testcmdwithnodocs
        ��AttributeErrorzCCalling help on a command with no docs should be handled gracefullyz;*** No help for 'testcmdwithnodocs'; __doc__ string missingz<Calling help on a command with no docs should print an error)rkr��assertIn)rrhr^rMrN�outputrrr�test_issue46434{s��zPdbTestCase.test_issue46434cCs�d}d}d}tdd�� }|�t�|��Wd�n1s<0Y|�tjd�|�||�\}}|�t	dd�|�
�D��d�dS)	Nz�
            from bar import bar

            def foo():
                bar()

            def nope():
                pass

            def foobar():
                foo()
                nope()

            foobar()
        z�
            from bar import bar
            break bar
            continue
            step
            step
            quit
        z5
            def bar():
                pass
        zbar.pyrccss|]}d|vVqdS)zmain.py(5)foo()->NoneNr��.0�lrrr�	<genexpr>�ryz.PdbTestCase.test_issue13183.<locals>.<genexpr>z+Fail to step into the caller after a return)rdrerfrgrPrrErk�
assertTrue�any�
splitlines)rrhr^ZbarrjrMrNrrr�test_issue13183�s.�zPdbTestCase.test_issue13183cCs�ttjd��&}|�t�d��d��Wd�n1s80Ytjdtjg}t	j
|t	jt	jt	jit
j�ddi�d�}|�|jj�|�d�\}}|�d	|d
�dS)Nrta
                import threading
                import pdb

                def start_pdb():
                    pdb.Pdb(readrc=False).set_trace()
                    x = 1
                    y = 1

                t = threading.Thread(target=start_pdb)
                t.start()�ascii�-urJrKrLscont
�Error�*Got an error running test script under PDB�rdrrFrerfrgr[rrRrSrTrUrVrWrXrPrMr�rYr�r�rrr�test_issue13120�s 
�$��zPdbTestCase.test_issue13120cCs�ttjd��&}|�t�d��d��Wd�n1s80Ytjdtjg}t	j
|t	jt	jt	jit
j�ddi�d�}|�|jj�|�d�\}}|�d	|d
�dS)Nrta�
                import threading
                import pdb

                evt = threading.Event()

                def start_pdb():
                    evt.wait()
                    pdb.Pdb(readrc=False).set_trace()

                t = threading.Thread(target=start_pdb)
                t.start()
                pdb.Pdb(readrc=False).set_trace()
                evt.set()
                t.join()r�r�rJrKrLs
cont
cont
r�r�r�r�rrr�test_issue36250�s �$��zPdbTestCase.test_issue36250cCs6d}d}d}|�||�\}}|�||d�||��dS)Nzdef f: pass
r�zSyntaxError:zE

Expected:
{}
Got:
{}
Fail to handle a syntax error in the debuggee.)rkr��format)rrhr^rwrMrNrrr�test_issue16180�s��zPdbTestCase.test_issue16180cCsLd}d}|�||�\}}d�dd�|��D��}|�|d�|�|d�dS)Nzprint('hello')z[
            continue
            run a b c
            run d e f
            quit
        �
cSsg|]}|���qSr)�strip)r��xrrr�
<listcomp>ryz/PdbTestCase.test_issue26053.<locals>.<listcomp>z#Restarting .* with arguments:
a b cz#Restarting .* with arguments:
d e f)rk�joinr�ZassertRegex)rrhr^rMrN�resrrr�test_issue26053�szPdbTestCase.test_issue26053c	Cs@t�d�}tj�dd�}�z
t����tdd��}|�d�Wd�n1sP0Ytdd��}|�|�Wd�n1s�0Yt	j
dg}tj|tj
tj
tj
d�}|�*|�d�\}}|�d	|�Wd�n1s�0YWd�n1�s0YW|du�r<|tjd<n|du�r:|tjd<0dS)
Nz_
            import pdb; pdb.Pdb(readrc=False).set_trace()

            print('hello')
        �HOME�.pdbrcrczinvalid
rbr�sq
s(NameError: name 'invalid' is not defined)rfrgrWrX�popr�temp_cwdrdrerrRrSrTrUrYr�)rrh�	save_homerjr_r`rMrNrrr�test_readrc_kwargs0

((
��D
�
zPdbTestCase.test_readrc_kwargcCs�tj�dd�}t����}td���tj�|d�}|tjj_	z`t
|d��}|�d�Wd�n1sf0Y|�t
��jdd�W|dur�|tjd<n|dur�|tjd<0Wd�n1s�0YWd�n1s�0YdS)Nr�zos.path.expanduserr�rc�invalidr)rWrXr�r�temp_dirr�pathr��
expanduserZreturn_valuerdrerur0r1ZrcLines)rr�r�Zrc_pathrjrrr�test_readrc_homedir's
(�zPdbTestCase.test_readrc_homedircCsxt�}d}t��@}|�td|��|�t�tjd��tj|d�Wd�n1sV0Y|�|�	�|d�dS)Nz"Nobody expects... blah, blah, blahz
sys.stdout�	set_trace)�headerr�)
rr�
enter_contextr�objectr0r1r�ru�getvalue)rrMr�Z	resourcesrrr�test_header4s*zPdbTestCase.test_headercCs:d}d}|�||�\}}|�tdd�|��D��|�dS)Nzprint("SUCCESS")�/
            continue
            quit
        css|]}d|vVqdS��SUCCESSNrr�rrrr�Dryz.PdbTestCase.test_run_module.<locals>.<genexpr>�rsr�r�r��rrhr^rMrNrrr�test_run_module=szPdbTestCase.test_run_modulecCs:d}d}|�||�\}}|�tdd�|��D��|�dS)NzQ
            if __name__ == '__main__':
                print("SUCCESS")
        r�css|]}d|vVqdSr�rr�rrrr�Pryz9PdbTestCase.test_module_is_run_as_main.<locals>.<genexpr>r�r�rrr�test_module_is_run_as_mainFsz&PdbTestCase.test_module_is_run_as_maincCsXd}d}|�||�\}}|�tdd�|��D��|�|�tdd�|��D��|�dS)Nz{
            if __name__ == '__main__':
                pass
                print("SUCCESS")
                pass
        z*
            b 3
            quit
        css|]}d|vVqdS)zBreakpoint 1 atNrr�rrrr�^ryz.PdbTestCase.test_breakpoint.<locals>.<genexpr>css|]}d|vVqdSr�rr�rrrr�_ry)rsr�r�r��allr�rrr�test_breakpointRs
zPdbTestCase.test_breakpointcCs2d}|�ddg|�\}}|�tj|�dd��dS)Nz(
            c
            quit
        rIr0�
r�)rar�r0Z_usage�replace)rr^rMrNrrr�test_run_pdb_with_pdbas
�z!PdbTestCase.test_run_pdb_with_pdbcCs�d}t�|�|d}t�|�t|d��Wd�n1s@0Y|�tj|�|�d|gd�\}}|�d|���dS)NrlrnrcrIr�z,ImportError: No module named t_main.__main__)	rrQrWrprdrPrar�r�)rrorrrMrNrrr�test_module_without_a_mainls

�z&PdbTestCase.test_module_without_a_maincCs�d}d}t�|�|d|}t�|�t|dd��Wd�n1sL0Y|�tj|�|�d|�dd�gd�\}}|�d	|�dS)
NZt_pkgrl�/rnrcrI�.r�z;'t_pkg.t_main' is a package and cannot be directly executed)	rrQrW�makedirsrdrPrar�r�)rZpkg_namero�modpathrMrNrrr�test_package_without_a_mainxs

�z'PdbTestCase.test_package_without_a_maincCs:d}d}|�||�\}}|�tdd�|��D��|�dS)NzY
                #This is a comment, on line 2

                print("SUCCESS")
        z
            quit
        css|]}d|vVqdS)z__main__.py(4)<module>()Nrr�rrrr��s��z=PdbTestCase.test_blocks_at_first_code_line.<locals>.<genexpr>r�r�rrr�test_blocks_at_first_code_line�s��z*PdbTestCase.test_blocks_at_first_code_linecCsnd|_t�|j�|jd}|jd}|jd}|�tj|j�t�|j�t|d�� }|�t�	d��Wd�n1s|0Yt|d�� }|�t�	d��Wd�n1s�0Yt|d�� }|�t�	d��Wd�n1s�0Yd	}|�
d
|jg|�\}}|�tdd�|�
�D��|�|�td
d�|�
�D���|�tdd�|�
�D���dS)Nrlrmrn�
/module.pyrc�6
                top_var = "VAR from top"
            z�
                from . import top_var
                from .module import var
                from . import module
                pass # We'll stop here and print the vars
            zY
                var = "VAR from module"
                var2 = "second var"
            zz
            b 5
            c
            p top_var
            p var
            p module.var2
            quit
        rIcss|]}d|vVqdS�zVAR from moduleNrr�rrrr��ryz4PdbTestCase.test_relative_imports.<locals>.<genexpr>css|]}d|vVqdS)zVAR from topNrr�rrrr��rycss|]}d|vVqdS)z
second varNrr�rrrr��ry�rorrQrPrWrprdrerfrgrar�r�r��rrqrrZmodule_filerjr^rM�_rrr�test_relative_imports�s$


...z!PdbTestCase.test_relative_importscCs:d|_t�|j�|jd}|jd}|jd}|�tj|j�t�|j�t|d�� }|�t�	d��Wd�n1s|0Yt|d�� }|�t�	d��Wd�n1s�0Yt|d�� }|�t�	d��Wd�n1s�0Yd	}|�
d
|jdg|�\}}|�tdd
�|�
�D��|�dS)Nrlz	/runme.pyrnr�rcr�zl
                from . import module
                pass # We'll stop here and print the vars
            z5
                var = "VAR from module"
            zQ
            b 3
            c
            p module.var
            quit
        rIz.runmecss|]}d|vVqdSr�rr�rrrr��ryzDPdbTestCase.test_relative_imports_on_plain_module.<locals>.<genexpr>r�r�rrr�%test_relative_imports_on_plain_module�s 


...z1PdbTestCase.test_relative_imports_on_plain_modulecCsBd�gd��}|�d|d�\}}|�|��dd�gd��dS)Nr�)zprint(zdebug print(zdebug doesnotexist�cr�r	)	z3(Pdb) *** SyntaxError: unexpected EOF while parsing�!(Pdb) ENTERING RECURSIVE DEBUGGERz-*** SyntaxError: unexpected EOF while parsing�LEAVING RECURSIVE DEBUGGERr�z> <string>(1)<module>()z9((Pdb)) *** NameError: name 'doesnotexist' is not definedr��(Pdb) �r�rkrur�)rr^rMr�rrr�test_errors_in_command�sz"PdbTestCase.test_errors_in_commandcs$�fdd�}|dd�|dd�dS)NcsVd�d|��dg�}��d|d�\}}��|��dd�dd|�d|��d	g�dS)
Nr�zrun �q�passr	z-> passz(Pdb) *** Cannot run z: r�r�)Zbad_arg�msgr^rMr�rrr�check�s��z*PdbTestCase.test_issue34266.<locals>.check�\zNo escaped character�"zNo closing quotationr)rr�rrr�test_issue34266�s
zPdbTestCase.test_issue34266cCsxt�d�}d}t���N}dtj�|���}|�||�\}}|�|�	d�d�
d�|�Wd�n1sj0YdS)N�Q
            import sys
            print('sys.path[0] is', sys.path[0])
        �c
q�(Pdb) sys.path[0] is r��r�)rfrgrr�rWr��realpathrkru�split�rstrip)rrhr^�cwdrwrMrNrrr�test_issue42384�s

zPdbTestCase.test_issue42384c
	Cst�d�}d}t����}tj�|�}tj�|d�}tj�|d�}d|��}t�|�t	tj�|d�d��}|�
|�Wd�n1s�0Yt�|�t�tj�|d�tj�|d��|�tj�dd�g|�\}}	|�
|�d�d	�d
�|�Wd�n1�s
0YdS)Nr�r��dir_one�dir_twor��foo.pyrcr�r�r�)rfrgrr�rWr�r�r�rprdre�symlinkrarur�r�)
rrhr^r�r�r�rwrjrMrNrrr�test_issue42384_symlink
s



(
 z#PdbTestCase.test_issue42384_symlinkc		Cs
t����}tdd��$}t�d�}|�|�Wd�n1s>0Ytj�|d�}t�	|�t�	tj�|d��tj�|d�}t|d��}|�d�Wd�n1s�0Y|�
dgd�\}}d}|�|�d�d	�
d
�|�Wd�n1s�0YdS)Nr�rcz�
                    print('The correct file was executed')

                    import os
                    os.chdir("subdir")
                �subdirz$print("The wrong file was executed")zc
c
qz#(Pdb) The correct file was executedr��r�)rr�rdrfrgrerWr�r�rprarur�r�)	rr�rj�sr�Z
wrong_filerMrNrwrrr�test_issue42383&s

(
(zPdbTestCase.test_issue42383N)&rrr rGrarkrsrxrzr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rZskip_unless_symlinkr�r�rrrrrCsD	
$ 
		
%
rCc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ChecklineTestscCst��dSr)�	linecache�
clearcacherrrr�setUp?szChecklineTests.setUpcCst�tj�dSrrDrrrrrGBszChecklineTests.tearDowncCsXttjd��}|�d�Wd�n1s,0Yt��}|�|�tjd�d�dS�Nrcz
print(123)r	)rdrrFrer0r1ru�	checkline�rrj�dbrrr�test_checkline_before_debuggingEs(z.ChecklineTests.test_checkline_before_debuggingcCs`ttjd��}|�d�Wd�n1s,0Yt��}|��|�|�tjd�d�dSr�)	rdrrFrer0r1�resetrur�r�rrr�test_checkline_after_resetKs
(z)ChecklineTests.test_checkline_after_resetcCs�t�d�}ttjd��}|�|�Wd�n1s60Yt|���d}tt	���:t
��}t|�D]}|�
|�tj|��qlWd�n1s�0YdS)Nz\
            # Comment
            """ docstring """
            ''' docstring '''

        rcr�)rfrgrdrrFre�lenr�rrr0r1�rangeZassertFalser�)rr�rjZ	num_linesr��linenorrr� test_checkline_is_not_executableRs
(z/ChecklineTests.test_checkline_is_not_executableN)rrr r�rGr�r�r�rrrrr�>s
r�cGs2ddlm}t�t�t�t�t�|�g}t�|�S)Nr)�test_pdb)	�testr�unittestZ	makeSuiterCr��doctestZDocTestSuiteZ	TestSuite)�argsrZsuitesrrr�
load_testscs�r�__main__)?rrWr0r�typesr�rrSrfr��
contextlibrr�iorrrZtest.test_doctestrZ
unittest.mockrZbdbrr
r�rr!r"r#r$r%r(r)r*r+r,�
ModuleType�mod�exec�__dict__r-r.r4r5r6r7r8r9r:r;r<r=r>r?r@rArBZTestCaserCr�rr�mainrrrr�<module>spk_*>
+*@;8=7*,/*/6%



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists