Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_pdb.cpython-35.opt-2.pyc



���]M��@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
Gdd�de�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zejd�Zedej�dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z d(d)�Z!d*d+�Z"d,d-�Z#d.d/�Z$Gd0d1�d1ej%�Z&d2d3�Z'e(d4kr�ej)�dS)5�N)�support)�
_FakeInputc@s4eZdZdd�Zdd�Zdd�ZdS)�PdbTestInputcCs
||_dS)N)�input)�selfr�r�-/opt/alt/python35/lib64/python3.5/test_pdb.py�__init__szPdbTestInput.__init__cCsFtj|_t|j�t_ttd�r9tj�nd|_dS)N�gettrace)�sys�stdin�
real_stdinrr�hasattrr
�
orig_trace)rrrr�	__enter__szPdbTestInput.__enter__cGs)|jt_|jr%tj|j�dS)N)r
rrr�settrace)r�excrrr�__exit__s	zPdbTestInput.__exit__N)�__name__�
__module__�__qualname__r	rrrrrrrsrcCsdS)Nrrrrr�test_pdb_displayhook!srcCsdS)Nrrrrr�test_pdb_basic_commands>srcCsdS)Nrrrrr�test_pdb_breakpoint_commands�srcCsdS)Nrrrrr�
do_nothingsrcCstd�dS)N�*)�printrrrr�do_somethingsrcCsdS)Nrrrrr�test_list_commands srcCsdS)Nrrrrr�test_post_mortem�srcCsdS)Nrrrrr�test_pdb_skip_modules�sr Zmodule_to_skipz6def foo_pony(callback): x = 1; callback(); return NonecCsdS)Nrrrrr�#test_pdb_skip_modules_with_callback�sr!cCsdS)Nrrrrr� test_pdb_continue_in_bottomframesr"cCs/ddl}t|jdd�|�|�dS)NrZnosigintT)�pdb�getattrZPdb)�method�argr#rrr�
pdb_invoke/sr'cCsdS)Nrrrrr�$test_pdb_run_with_incorrect_argument5sr(cCsdS)Nrrrrr�test_pdb_run_with_code_objectEsr)cCsdS)Nrrrrr�&test_next_until_return_at_return_event[sr*cCsdS)Nrrrrr�#test_pdb_next_command_for_generator�sr+cCsdS)Nrrrrr�%test_pdb_return_command_for_generator�sr,cCsdS)Nrrrrr�$test_pdb_until_command_for_generatorsr-cCsdS)Nrrrrr�+test_pdb_next_command_in_generator_for_loop:sr.cCsdS)Nrrrrr�!test_pdb_next_command_subiteratorcsr/cCsdS)Nrrrrr�test_pdb_issue_20766�sr0c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�PdbTestCasec	Csd}t|d��}|jtj|��WdQRX|jtj|�|jtjd�tj	dd|g}d}}t
j|dt
jdt
jdt
j
��%}|jtj|��\}}WdQRX|o�tj|�}|o�tj|�}||fS)	Nzmain.py�w�__pycache__z-mr#�stdoutr�stderr)�open�write�textwrap�dedent�
addCleanupr�unlink�rmtreer�
executable�
subprocess�Popen�PIPE�STDOUT�communicate�str�encode�bytes�decode)	r�script�commands�filename�f�cmdr4r5�procrrr�run_pdb�s
	%zPdbTestCase.run_pdbcCs�tj|�}ttjd��}|j|�WdQRX|sDdn|dtj|df}|j|tj|tj��dS)Nr2r�)	r8r9r6r�TESTFNr7ZassertEqualr#Z
find_function)rZfile_content�	func_name�expectedrJrrr�_assert_find_function�sz!PdbTestCase._assert_find_functioncCs|jddd�dS)N�Zfoo)rR)rrrr�test_find_function_empty_file�sz)PdbTestCase.test_find_function_empty_filecCs|jddd�dS)Nz�            def foo():
                pass

            def bar():
                pass

            def quux():
                pass
            �bar�)rUrV)rR)rrrr�test_find_function_found�s
z$PdbTestCase.test_find_function_foundcCs�ttjd��}|jd�WdQRXtjddtjg}tj|dtjdtjdtj	�}|j
|jj�|j
d�\}}|jd	|d
�dS)N�wbsprint("testing my pdb")
z-mr#r4rr5squit
sSyntaxErrorz0Got a syntax error running test script under PDB)r6rrOr7rr=r>r?r@rAr:r4�closerB�assertNotIn)rrJrKrLr4r5rrr�test_issue7964�s		zPdbTestCase.test_issue7964cCs�d}d}d}tdd��}|jtj|��WdQRX|jtjd�|j||�\}}|jt	dd�|j
�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.pyr2css|]}d|kVqdS)zmain.py(5)foo()->NoneNr)�.0�lrrr�	<genexpr>sz.PdbTestCase.test_issue13183.<locals>.<genexpr>z+Fail to step into the caller after a return)r6r7r8r9r:rr;rMZ
assertTrue�any�
splitlines)rrGrHrUrJr4r5rrr�test_issue13183�szPdbTestCase.test_issue13183cCs�tjd�ttjd��&}|jtjd�jd��WdQRXtj	dtjg}t
j|dt
jdt
jdt
j
�}|j|jj�|jd	�\}}|jd
|j�d�dS)N�	threadingrXa
                import threading
                import pdb

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

                t = threading.Thread(target=start_pdb)
                t.start()�asciiz-ur4rr5scont
�Errorz*Got an error running test script under PDB)r�
import_moduler6rOr7r8r9rDrr=r>r?r@rAr:r4rYrBrZrF)rrJrKrLr4r5rrr�test_issue13210s

		zPdbTestCase.test_issue13210cCsMd}d}d}|j||�\}}|j||dj||��dS)Nzdef f: pass
rSzSyntaxError:zE

Expected:
{}
Got:
{}
Fail to handle a syntax error in the debuggee.)rMZassertIn�format)rrGrHrQr4r5rrr�test_issue16180-szPdbTestCase.test_issue16180cCstjtj�dS)N)rr;rO)rrrr�tearDown9szPdbTestCase.tearDownN)rrrrMrRrTrWr[rarfrhrirrrrr1�s$r1cGs;ddlm}tjt�tj|�g}tj|�S)Nr)�test_pdb)�testrj�unittestZ	makeSuiter1�doctestZDocTestSuiteZ	TestSuite)�argsrjZsuitesrrr�
load_tests=sro�__main__)*rmr#r�typesrlr>r8rkrZtest.test_doctestr�objectrrrrrrrrr �
ModuleType�mod�exec�__dict__r!r"r'r(r)r*r+r,r-r.r/r0ZTestCaser1ror�mainrrrr�<module>sFnn`>+*A;7,)/�