Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_tools/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_tools/__pycache__/test_pindent.cpython-39.opt-1.pyc

a

XC?h�!�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZe�Gdd�dej
�Zedkr|e��dS)	z4Tests for the pindent script in the Tools directory.�N)�support)�assert_python_ok)�
scriptsdir�skip_if_missingc@sreZdZej�ed�Zdd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�PindentTestsz
pindent.pyc	Csht|��L}t|��$}|�|��|���Wd�n1s<0YWd�n1sZ0YdS�N)�open�assertEqual�	readlines)�selfZfn1Zfn2�f1�f2�r�A/opt/alt/python39/lib64/python3.9/test/test_tools/test_pindent.py�assertFileEqualszPindentTests.assertFileEqualcGs^tjtj|jf|tjtjdd��}|�|�\}}Wd�n1sF0Y|�|�|S)NT)�stdin�stdoutZuniversal_newlines)�
subprocess�Popen�sys�
executable�script�PIPEZcommunicateZassertIsNone)r�source�args�proc�out�errrrr�pindents�,
zPindentTests.pindentcCsd�dd�|��D��dS)N�
css|]}|��VqdSr)�lstrip)�.0�linerrr�	<genexpr>!�z+PindentTests.lstriplines.<locals>.<genexpr>)�join�
splitlines)r�datarrr�lstriplines szPindentTests.lstriplinesc	Cs&d|_t����}tj�|d�}t|j��}|��}Wd�n1sH0Yt|d��}|�	|�Wd�n1s|0Yt
|jd|�\}}}|�|d�|�|d�|d}|�tj�
|��t|�� }|�|��|�Wd�n1s�0Yt|��}|��}	Wd�n1�s,0Yt|	dd�|�|�|	d�|�|�|�|d�|	�t
|jd|�\}}}|�|d�|�|d�t|�� }|�|��|	�Wd�n1�s�0Yt|�� }|�|��|�Wd�n1�s0Y|�|�}
t|d��}|�	|
�Wd�n1�s@0Yt
|jd|�\}}}|�|d�|�|d�t|�� }|�|��|
�Wd�n1�s�0Yt|��}|��}Wd�n1�s�0Yt|dd�|�|�|
d�|�Wd�n1�s0YdS)	Nz_test.py�w�-dr$�~�exec�-c�-r)ZmaxDiffrZtemp_dir�os�pathr%rr�read�writerr	Z
assertTrue�exists�compilerr()rZ	directoryZ	data_path�f�closedZrcrrZbackup�clean�brokenZindentedrrr�
test_selftest#sL&(
.
(
0
0
*
0
(zPindentTests.test_selftestc	CsP|�|�|d�|�|�|�|d�|�|�|�}|�|�|dddd�|�dS)Nr-r*r.�-e�-s�4)r	rr(�rr7r6r8rrr�pindent_testNs
zPindentTests.pindent_testcCs$t�d�}t�d�}|�||�dS)Na:            if a:
                pass

            if a:
                pass
            else:
                pass

            if a:
                pass
            elif:
                pass
            else:
                pass

            while a:
                break

            while a:
                break
            else:
                pass

            for i in a:
                break

            for i in a:
                break
            else:
                pass

            try:
                pass
            finally:
                pass

            try:
                pass
            except TypeError:
                pass
            except ValueError:
                pass
            else:
                pass

            try:
                pass
            except TypeError:
                pass
            except ValueError:
                pass
            finally:
                pass

            with a:
                pass

            class A:
                pass

            def f():
                pass
            a`            if a:
                pass
            # end if

            if a:
                pass
            else:
                pass
            # end if

            if a:
                pass
            elif:
                pass
            else:
                pass
            # end if

            while a:
                break
            # end while

            while a:
                break
            else:
                pass
            # end while

            for i in a:
                break
            # end for

            for i in a:
                break
            else:
                pass
            # end for

            try:
                pass
            finally:
                pass
            # end try

            try:
                pass
            except TypeError:
                pass
            except ValueError:
                pass
            else:
                pass
            # end try

            try:
                pass
            except TypeError:
                pass
            except ValueError:
                pass
            finally:
                pass
            # end try

            with a:
                pass
            # end with

            class A:
                pass
            # end class A

            def f():
                pass
            # end def f
            ��textwrap�dedentr>�rr7r6rrr�test_statementsTs
A
MzPindentTests.test_statementscCs$t�d�}t�d�}|�||�dS)Nz�            def foobar(a, b):
                if a == b:
                    a = a+1
                elif a < b:
                    b = b-1
                    if b > a: a = a-1
                else:
                    print 'oops!'
            aJ            def foobar(a, b):
                if a == b:
                    a = a+1
                elif a < b:
                    b = b-1
                    if b > a: a = a-1
                    # end if
                else:
                    print 'oops!'
                # end if
            # end def foobar
            r?rBrrr�test_multilevel�s



zPindentTests.test_multilevelc	Cs�t�d�}t�d�}|�|�|d�|�|�|�|d�|�|�|�}|�|�|dddd�|�t�d	�}t�d
�}|�|�|d�|�|�|�|d�|�|�|�}|�|�|d�|�dS)Nz\            if a:
                     if b:
                              pass
            z�            if a:
                     if b:
                              pass
                     # end if
            # end if
            r-r*r.r:r;�9zD            if a:
            	if b:
            		pass
            zo            if a:
            	if b:
            		pass
            	# end if
            # end if
            )r@rAr	rr(r=rrr�test_preserve_indents�s





z"PindentTests.test_preserve_indentscCs@t�d�}t�d�}|�|�|d�|�|�|�|d�|�dS)Nz�            class\
            \
             A:
               def            \
            f:
                  pass
            z�            class\
            \
             A:
               def            \
            f:
                  pass
               # end def f
            # end class A
            r-r*)r@rAr	rrBrrr�test_escaped_newline!s
	
z!PindentTests.test_escaped_newlinecCs$t�d�}t�d�}|�||�dS)Nz4            if a:

                pass
            zI            if a:

                pass
            # end if
            r?rBrrr�test_empty_line9s

zPindentTests.test_empty_linecCs$t�d�}t�d�}|�||�dS)Nz#            if a: pass
            z8            if a: pass
            # end if
            r?rBrrr�test_onelineGs

zPindentTests.test_onelineN)�__name__�
__module__�__qualname__r/r0r%rrrrr(r9r>rCrDrFrGrHrIrrrrrs	+"r�__main__)�__doc__r/rZunittestrr@�testrZtest.support.script_helperrZtest.test_toolsrrZTestCaserrJ�mainrrrr�<module>sD