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: //usr/local/lib/python3.7/test/test_tools/__pycache__/test_pindent.cpython-37.pyc
B

"��g�!�@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
Cs@t|��.}t|��}|�|��|���WdQRXWdQRXdS)N)�open�assertEqual�	readlines)�selfZfn1Zfn2�f1�f2�r
�8/usr/local/lib/python3.7/test/test_tools/test_pindent.py�assertFileEqualszPindentTests.assertFileEqualc	GsJtjtj|jf|tjtjdd��}|�|�\}}WdQRX|�|�|S)NT)�stdin�stdoutZuniversal_newlines)�
subprocess�Popen�sys�
executable�script�PIPEZcommunicateZassertIsNone)r
�source�args�proc�out�errr
r
r�pindents

zPindentTests.pindentcCsd�dd�|��D��dS)N�
css|]}|��VqdS)N)�lstrip)�.0�liner
r
r�	<genexpr>!sz+PindentTests.lstriplines.<locals>.<genexpr>)�join�
splitlines)r
�datar
r
r�lstriplines szPindentTests.lstriplinesc
CsPd|_t����6}tj�|d�}t|j��}|��}WdQRXt|d��}|�	|�WdQRXt
|jd|�\}}}|�|d�|�|d�|d}|�tj�
|��t|��}|�|��|�WdQRXt|��}|��}	WdQRXt|	dd�|�|�|	d�|�|�|�|d�|	�t
|jd|�\}}}|�|d�|�|d�t|��}|�|��|	�WdQRXt|��}|�|��|�WdQRX|�|�}
t|d��}|�	|
�WdQRXt
|jd|�\}}}|�|d�|�|d�t|��}|�|��|
�WdQRXt|��}|��}WdQRXt|dd�|�|�|
d�|�WdQRXdS)	Nz_test.py�wz-d��~�execz-cz-r)ZmaxDiffrZtemp_dir�os�pathr#rr�read�writerrZ
assertTrue�exists�compilerr&)r
Z	directoryZ	data_path�f�closedZrcrrZbackup�clean�brokenZindentedr
r
r�
test_selftest#sL






zPindentTests.test_selftestc	CsP|�|�|d�|�|�|�|d�|�|�|�}|�|�|dddd�|�dS)Nz-cz-dz-rz-ez-s�4)rrr&)r
r3r2r4r
r
r�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�dedentr7)r
r3r2r
r
r�test_statementsTs
?LzPindentTests.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
            )r8r9r7)r
r3r2r
r
r�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
            z-cz-dz-rz-ez-s�9zD            if a:
            	if b:
            		pass
            zo            if a:
            	if b:
            		pass
            	# end if
            # end if
            )r8r9rrr&)r
r3r2r4r
r
r�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
            z-cz-d)r8r9rr)r
r3r2r
r
r�test_escaped_newline!s
z!PindentTests.test_escaped_newlinecCs$t�d�}t�d�}|�||�dS)Nz4            if a:

                pass
            zI            if a:

                pass
            # end if
            )r8r9r7)r
r3r2r
r
r�test_empty_line9s
zPindentTests.test_empty_linecCs$t�d�}t�d�}|�||�dS)Nz#            if a: pass
            z8            if a: pass
            # end if
            )r8r9r7)r
r3r2r
r
r�test_onelineGs
zPindentTests.test_onelineN)�__name__�
__module__�__qualname__r+r,r#rrrrr&r5r7r:r;r=r>r?r@r
r
r
rrs	+"r�__main__)�__doc__r+rZunittestrr8ZtestrZtest.support.script_helperrZtest.test_toolsrrZTestCaserrA�mainr
r
r
r�<module>sD