Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/test/test_tools/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/test_tools/__pycache__/test_pindent.cpython-310.pyc

o

0�i�!�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZe�Gdd�dej�Zed	krFe��dSdS)
z4Tests for the pindent script in the Tools directory.�N)�support)�	os_helper)�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	Cszt|��/}t|��}|�|��|���Wd�n1swYWd�dSWd�dS1s6wYdS�N)�open�assertEqual�	readlines)�selfZfn1Zfn2�f1�f2�r�C/opt/alt/python310/lib64/python3.10/test/test_tools/test_pindent.py�assertFileEqualsP�zPindentTests.assertFileEqualcGs^tjtj|jf|tjtjdd��}|�|�\}}Wd�n1s#wY|�|�|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>"s�z+PindentTests.lstriplines.<locals>.<genexpr>)�join�
splitlines)r�datarrr�lstriplines!szPindentTests.lstriplinesc	Cs"d|_t����~}tj�|d�}t|j��}|��}Wd�n1s$wYt|d��
}|�	|�Wd�n1s>wYt
|jd|�\}}}|�|d�|�|d�|d}|�tj�
|��t|��}|�|��|�Wd�n1s}wYt|��}|��}	Wd�n1s�wYt|	dd�|�|�|	d�|�|�|�|d�|	�t
|jd|�\}}}|�|d�|�|d�t|��}|�|��|	�Wd�n1s�wYt|��}|�|��|�Wd�n1s�wY|�|�}
t|d��
}|�	|
�Wd�n	1�swYt
|jd|�\}}}|�|d�|�|d�t|��}|�|��|
�Wd�n	1�sPwYt|��}|��}Wd�n	1�siwYt|dd�|�|�|
d�|�Wd�dS1�s�wYdS)	Nz_test.py�w�-d��~�exec�-c�-r)ZmaxDiffrZtemp_dir�os�pathr%r	r�read�writerr
Z
assertTrue�exists�compilerr()rZ	directoryZ	data_path�f�closedZrcrrZbackup�clean�brokenZindentedrrr�
test_selftest$s`
��
�

�
�
�
�
�

�$�zPindentTests.test_selftestc	CsP|�|�|d�|�|�|�|d�|�|�|�}|�|�|dddd�|�dS)Nr.r*r/�-e�-s�4)r
rr(�rr8r7r9rrr�pindent_testOs
zPindentTests.pindent_testcC�$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?�rr8r7rrr�test_statementsUs

AMzPindentTests.test_statementscCr@)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
            rArDrrr�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
            )rBrCr
rr(r>rrr�test_preserve_indentss





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*)rBrCr
rrDrrr�test_escaped_newline"s

	z!PindentTests.test_escaped_newlinecCr@)Nz4            if a:

                pass
            zI            if a:

                pass
            # end if
            rArDrrr�test_empty_line:s

zPindentTests.test_empty_linecCr@)Nz#            if a: pass
            z8            if a: pass
            # end if
            rArDrrr�test_onelineHs

zPindentTests.test_onelineN)�__name__�
__module__�__qualname__r0r1r%rrrrr(r:r?rErFrHrIrJrKrrrrrs	+"r�__main__)�__doc__r0rZunittestrrB�testrZtest.supportrZtest.support.script_helperrZtest.test_toolsrrZTestCaserrL�mainrrrr�<module>s"D�