HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/test_tools/__pycache__/test_pindent.cpython-38.pyc
U

1D�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|��}|�|��|���W5QRXW5QRXdS�N)�open�assertEqual�	readlines)�selfZfn1Zfn2�f1�f2�r�;/opt/cppython/lib/python3.8/test/test_tools/test_pindent.py�assertFileEqualszPindentTests.assertFileEqualc	GsJtjtj|jf|tjtjdd��}|�|�\}}W5QRX|�|�|S)NT)�stdin�stdout�universal_newlines)�
subprocess�Popen�sys�
executable�script�PIPE�communicateZassertIsNone)r�source�args�proc�out�errrrr�pindents�
zPindentTests.pindentcCsd�dd�|��D��dS)N�
css|]}|��VqdSr)�lstrip)�.0�linerrr�	<genexpr>!sz+PindentTests.lstriplines.<locals>.<genexpr>)�join�
splitlines)r�datarrr�lstriplines szPindentTests.lstriplinesc
CsPd|_t����6}tj�|d�}t|j��}|��}W5QRXt|d��}|�	|�W5QRXt
|jd|�\}}}|�|d�|�|d�|d}|�tj�
|��t|��}|�|��|�W5QRXt|��}|��}	W5QRXt|	dd�|�|�|	d�|�|�|�|d�|	�t
|jd|�\}}}|�|d�|�|d�t|��}|�|��|	�W5QRXt|��}|�|��|�W5QRX|�|�}
t|d��}|�	|
�W5QRXt
|jd|�\}}}|�|d�|�|d�t|��}|�|��|
�W5QRXt|��}|��}W5QRXt|dd�|�|�|
d�|�W5QRXdS)	Nz_test.py�w�-d��~�exec�-c�-r)ZmaxDiffrZtemp_dir�os�pathr&rr�read�writerr	Z
assertTrue�exists�compiler r))rZ	directoryZ	data_path�f�closed�rcrrZbackup�clean�brokenZindentedrrr�
test_selftest#sL






zPindentTests.test_selftestc	CsP|�|�|d�|�|�|�|d�|�|�|�}|�|�|dddd�|�dS)Nr/r+r0�-e�-s�4)r	r r)�rr:r8r;rrr�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�dedentrA�rr:r8rrr�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
            rBrErrr�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+r0r=r>�9zD            if a:
            	if b:
            		pass
            zo            if a:
            	if b:
            		pass
            	# end if
            # end if
            )rCrDr	r r)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+)rCrDr	r rErrr�test_escaped_newline!s
	
z!PindentTests.test_escaped_newlinecCs$t�d�}t�d�}|�||�dS)Nz4            if a:

                pass
            zI            if a:

                pass
            # end if
            rBrErrr�test_empty_line9s

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

zPindentTests.test_onelineN)�__name__�
__module__�__qualname__r1r2r&rrrr r)r<rArFrGrIrJrKrLrrrrrs	+"r�__main__)�__doc__r1rZunittestrrC�testrZtest.support.script_helperrZtest.test_toolsrrZTestCaserrM�mainrrrr�<module>sD