a
    Ø
þd±ö  ã                   @   s  d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ ej ej ej e¡¡¡Zejd
dddgZG dd„ dejƒZG dd„ de	jƒZG dd„ de	jƒZG dd„ de	jƒZ G dd„ de	jƒZ!G dd„ dejƒZ"G dd„ de	jƒZ#G dd„ de#ƒZ$G dd„ de#ƒZ%G d d!„ d!e#ƒZ&e'd"krŒe	 (¡  dS )#zTests for yapf.yapf.é    N)ÚStringIO)Útokenize)Úerrors)Ústyle)Úyapf_api)Úutils)Úyapf_test_helperz-mÚyapfz--verifyz--no-local-stylec                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚFormatCodeTestc                 C   s"   t j|dd\}}|  ||¡ d S )Nr	   ©Ústyle_config)r   Ú
FormatCodeÚassertCodeEqual©ÚselfÚunformatted_codeÚexpected_formatted_codeÚformatted_codeÚ_© r   ú\/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/yapftests/yapf_test.pyÚ_Check-   s    ÿ
zFormatCodeTest._Checkc                 C   s   t  d¡}|  ||¡ d S )Nz        print('foo')
        ©ÚtextwrapÚdedentr   )r   r   r   r   r   Ú
testSimple2   s    
zFormatCodeTest.testSimplec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz        if True:
          passú(        if True:
          pass
        r   ©r   r   r   r   r   r   ÚtestNoEndingNewline8   s    

z"FormatCodeTest.testNoEndingNewlineN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r
   +   s   r
   c                   @   s´   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+S ),ÚFormatFileTestc                 C   s   t  ¡ | _d S ©N©ÚtempfileÚmkdtempÚtest_tmpdir©r   r   r   r   ÚsetUpE   s    zFormatFileTest.setUpc                 C   s   t  | j¡ d S r#   ©ÚshutilÚrmtreer'   r(   r   r   r   ÚtearDownH   s    zFormatFileTest.tearDownc                 C   sN   ||krJd}|d7 }|d  | ¡ ¡7 }|d7 }|d  | ¡ ¡7 }|  |¡ d S )NzCode format mismatch:
zExpected:
 >z
 > z
Actual:
 >)ÚjoinÚ
splitlinesZfail)r   Zexpected_codeÚcodeÚmsgr   r   r   r   K   s    zFormatFileTest.assertCodeEqualc                 C   s   t  d¡}t  d¡}t  d¡}t | j|¡P}tj|dd\}}}|  ||¡ tj|dd\}}}|  ||¡ W d   ƒ n1 s‚0    Y  d S )Nú'        if True:
         pass
        z*        if True:
            pass
        r   Úpep8r   r	   ©r   r   r   ÚTempFileContentsr'   r   Ú
FormatFiler   )r   r   Zexpected_formatted_code_pep8Zexpected_formatted_code_yapfÚfilepathr   r   r   r   r   ÚtestFormatFileU   s    


zFormatFileTest.testFormatFilec                 C   sf   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  d S )Nz[        if a:    b

        # yapf: disable
        if f:    g

        if h:    i
        zX        if a: b

        # yapf: disable
        if f:    g

        if h:    i
        r3   r   r4   ©r   r   r   r7   r   r   r   r   r   ÚtestDisableLinesPatterni   s
    

z&FormatFileTest.testDisableLinesPatternc                 C   sf   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  d S )Nzr        if a:    b

        # yapf: disable
        if f:    g
        # yapf: enable

        if h:    i
        zl        if a: b

        # yapf: disable
        if f:    g
        # yapf: enable

        if h: i
        r3   r   r4   r9   r   r   r   Ú"testDisableAndReenableLinesPattern~   s
    
	
	z1FormatFileTest.testDisableAndReenableLinesPatternc                 C   sf   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  d S )Nzh        if a:    b

        # fmt: off
        if f:    g
        # fmt: on

        if h:    i
        zb        if a: b

        # fmt: off
        if f:    g
        # fmt: on

        if h: i
        r3   r   r4   r9   r   r   r   ÚtestFmtOnOff•   s
    
	
	zFormatFileTest.testFmtOnOffc                 C   s¾   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 s°0    Y  d S )Nzå        if a:    b

        # This is a multiline comment that disables YAPF.
        # yapf: disable
        if f:    g
        # yapf: enable
        # This is a multiline comment that enables YAPF.

        if h:    i
        zß        if a: b

        # This is a multiline comment that disables YAPF.
        # yapf: disable
        if f:    g
        # yapf: enable
        # This is a multiline comment that enables YAPF.

        if h: i
        r3   r   z¦      def foo_function():
          # some comment
          # yapf: disable

          foo(
          bar,
          baz
          )

          # yapf: enable
      r4   )r   r   r   r7   r   r   r0   r   r   r   Ú!testDisablePartOfMultilineComment¬   s    

*
z0FormatFileTest.testDisablePartOfMultilineCommentc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )Nav          # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        r3   r   r4   ©r   r0   r7   r   r   r   r   r   ÚtestEnabledDisabledSameCommentØ   s    
z-FormatFileTest.testEnabledDisabledSameCommentc                 C   s˜   t  d¡}t  d¡}t  d¡}t | j|¡X}tj|ddgd\}}}|  ||¡ tj|ddgd\}}}|  ||¡ W d   ƒ n1 sŠ0    Y  d S )NzC        if a:    b

        if f:    g

        if h:    i
        z@        if a: b

        if f:    g

        if h:    i
        z@        if a:    b

        if f: g

        if h:    i
        r3   )é   é   )r   Úlines)é   rC   r4   )r   r   Z"expected_formatted_code_lines1and2Zexpected_formatted_code_lines3r7   r   r   r   r   r   ÚtestFormatFileLinesSelectionå   s    


ÿÿz+FormatFileTest.testFormatFileLinesSelectionc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  d|¡ W d   ƒ n1 sN0    Y  d S )Nr2   T)Ú
print_diffz+  pass)r   r   r   r5   r'   r   r6   ÚassertIn)r   r   r7   Údiffr   r   r   r   ÚtestFormatFileDiff  s    
z!FormatFileTest.testFormatFileDiffc              	   C   s¨   d}d}t  | j|¡~}tj|dd\}}}|  |d ¡ t|ƒ }|  || ¡ ¡ W d   ƒ n1 sf0    Y  | j	t
tj|ddd W d   ƒ n1 sš0    Y  d S )NzTrue==False
zTrue == False
T)Úin_place)rI   rE   )r   r5   r'   r   r6   ÚassertEqualÚopenr   ÚreadÚassertRaisesÚ
ValueError)r   r   r   r7   Úresultr   Úfdr   r   r   ÚtestFormatFileInPlace  s    
.ûz$FormatFileTest.testFormatFileInPlacec                 C   sJ   |   t¡}t d¡ W d   ƒ n1 s*0    Y  |  t|jƒd¡ d S )Nznot_a_file.pyz4[Errno 2] No such file or directory: 'not_a_file.py')rM   ÚIOErrorr   r6   rJ   ÚstrÚ	exception)r   Úcontextr   r   r   Ú
testNoFile  s    (þzFormatFileTest.testNoFilec                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )NzŠ        foo = [# A list of things
               # bork
            'one',
            # quark
            'two'] # yapf: disable
        r3   r   r4   r>   r   r   r   ÚtestCommentsUnformatted$  s    
z&FormatFileTest.testCommentsUnformattedc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )NzP        # yapf: disable
        a = [
        1]
        # yapf: enable
        r3   r   r4   r>   r   r   r   Ú)testDisabledHorizontalFormattingOnNewLine0  s    
z8FormatFileTest.testDisabledHorizontalFormattingOnNewLinec                 C   sf   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  d S )Nzf        def f():
          x = y + 42 ; z = n * 42
          if True: a += 1 ; b += 1; c += 1
        z¡        def f():
            x = y + 42
            z = n * 42
            if True:
                a += 1
                b += 1
                c += 1
        r3   r   r4   r9   r   r   r   Ú testSplittingSemicolonStatements;  s
    

	z/FormatFileTest.testSplittingSemicolonStatementsc                 C   sf   t  d¡}t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sX0    Y  d S )Nzw        def f():
          x = y + 42 ; z = n * 42  # yapf: disable
          if True: a += 1 ; b += 1; c += 1
        z¨        def f():
            x = y + 42 ; z = n * 42  # yapf: disable
            if True:
                a += 1
                b += 1
                c += 1
        r3   r   r4   r9   r   r   r   ÚtestSemicolonStatementsDisabledN  s
    

z.FormatFileTest.testSemicolonStatementsDisabledc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )Nz7        # yapf: disable
        if True: a ; b
        r3   r   r4   r>   r   r   r   Ú(testDisabledSemiColonSeparatedStatements`  s    
z7FormatFileTest.testDisabledSemiColonSeparatedStatementsc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )Nzý        # yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   r4   r>   r   r   r   Ú'testDisabledMultilineStringInDictionaryi  s    
z6FormatFileTest.testDisabledMultilineStringInDictionaryc                 C   s\   t  d¡}t | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sN0    Y  d S )Na          # TODO(fix formatting): yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   r4   r>   r   r   r   ÚtestDisabledWithPrecedingText|  s    
z,FormatFileTest.testDisabledWithPrecedingTextc                 C   sV   d}t  | j|¡0}tj|dd\}}}|  ||¡ W d   ƒ n1 sH0    Y  d S )Nzclass _():
  pass
r	   r   )r   r5   r'   r   r6   r   r>   r   r   r   ÚtestCRLFLineEnding  s    z!FormatFileTest.testCRLFLineEndingN)r   r    r!   r)   r-   r   r8   r:   r;   r<   r=   r?   rD   rH   rQ   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r   r   r   r   r"   C   s*   
,		r"   c                   @   sª  e Zd ZdZedd„ ƒZedd„ ƒZdgdd„Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Z d;d<„ Z!d=d>„ Z"d?d@„ Z#dAdB„ Z$dCdD„ Z%dEdF„ Z&dGdH„ Z'dIdJ„ Z(dKdL„ Z)dMdN„ Z*dOdP„ Z+dQdR„ Z,dSdT„ Z-dUdV„ Z.dWdX„ Z/dYdZ„ Z0d[d\„ Z1d]d^„ Z2d_d`„ Z3dadb„ Z4dcdd„ Z5dedf„ Z6dS )hÚCommandLineTestz1Test how calling yapf from the command line acts.c                 C   s   t  ¡ | _d S r#   r$   ©Úclsr   r   r   Ú
setUpClass™  s    zCommandLineTest.setUpClassc                 C   s   t  | j¡ d S r#   r*   r`   r   r   r   ÚtearDownClass  s    zCommandLineTest.tearDownClassNc           	      C   s\   t |pg  }tj|tjtjtj|d}| | d¡¡\}}|  |d¡ |  | d¡|¡ dS )a¶  Check that yapf reformats the given code as expected.

    Invokes yapf in a subprocess, piping the unformatted code into its stdin.
    Checks that the formatted output is as expected.

    Arguments:
      unformatted: unformatted code - input to yapf
      expected: expected formatted code at the output of yapf
      extra_options: iterable of extra command-line options to pass to yapf
      env: dict of environment variables.
    )ÚstdoutÚstdinÚstderrÚenvz	utf-8-sigó    úutf-8N)	ÚYAPF_BINARYÚ
subprocessÚPopenÚPIPEÚcommunicateÚencoderJ   ZassertMultiLineEqualÚdecode)	r   ZunformattedÚexpectedÚextra_optionsrg   ZcmdlineÚpÚreformatted_codeÚ
stderrdatar   r   r   ÚassertYapfReformats¡  s    ûÿz#CommandLineTest.assertYapfReformatsc              	   C   s¨   t  d¡}t  d¡}tj| j|ddb}t td|g ¡}| ¡  t	j
|ddd}| ¡ }W d   ƒ n1 sp0    Y  W d   ƒ n1 sŽ0    Y  |  ||¡ d S )	Nú,        def foo():
          x = 37
        ú.        def foo():
            x = 37
        ú.py©Úsuffixú
--in-placeÚrÚ ©ÚmodeÚnewline©r   r   r   r5   r'   rk   rl   rj   ÚwaitÚiorK   rL   rJ   ©r   r   r   r7   rs   rP   rt   r   r   r   ÚtestInPlaceReformatting½  s    

ÿDz'CommandLineTest.testInPlaceReformattingc              	   C   sž   d}d}t j| j|ddd}t td|g ¡}| ¡  tj|dddd	}| 	¡ }W d   ƒ n1 sf0    Y  W d   ƒ n1 s„0    Y  |  
||¡ d S )
Nz

Ú
ry   rz   r|   r}   ri   r~   ©r€   Úencodingr   ©r   r5   r'   rk   rl   rj   rƒ   r„   rK   rL   rJ   r…   r   r   r   ÚtestInPlaceReformattingBlankÎ  s    ÿDz,CommandLineTest.testInPlaceReformattingBlankc              	   C   sž   d}d}t j| j|ddd}t td|g ¡}| ¡  tj|dddd	}| 	¡ }W d   ƒ n1 sf0    Y  W d   ƒ n1 s„0    Y  |  
||¡ d S )
Nz

z
ry   rz   r|   r}   ri   r~   rˆ   rŠ   r…   r   r   r   Ú%testInPlaceReformattingWindowsNewLineÙ  s    ÿDz5CommandLineTest.testInPlaceReformattingWindowsNewLinec              	   C   s¨   t  d¡}t  d¡}tj| j|ddb}t td|g ¡}| ¡  t	j
|ddd}| ¡ }W d   ƒ n1 sp0    Y  W d   ƒ n1 sŽ0    Y  |  ||¡ d S )	Nzdef foo(): x = 37rx   ry   rz   r|   r}   r~   r   r‚   r…   r   r   r   Ú testInPlaceReformattingNoNewLineä  s    

ÿDz0CommandLineTest.testInPlaceReformattingNoNewLinec              	   C   sž   d}d}t j| j|ddd}t td|g ¡}| ¡  tj|dddd}| 	¡ }W d   ƒ n1 sf0    Y  W d   ƒ n1 s„0    Y  |  
||¡ d S )Nr~   ry   rz   r|   r}   ri   rˆ   rŠ   r…   r   r   r   ÚtestInPlaceReformattingEmptyò  s    ÿDz,CommandLineTest.testInPlaceReformattingEmptyc              	   C   s|   dD ]r\}}t j| j|ddH}tjtdd|g dd}|rB| jn| j}|d|› |ƒ W d   ƒ q1 sl0    Y  qd S )	N))z1==2T)z1 == 2Fry   rz   r|   z--print-modifiedT)Útextz
Formatted )r   r5   r'   rk   Úcheck_outputrj   rF   ZassertNotIn)r   r   Z
has_changer7   ÚoutputÚcheckr   r   r   ÚtestPrintModifiedý  s    ÿþz!CommandLineTest.testPrintModifiedc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nrw   rx   ©r   r   rv   r   r   r   r   ÚtestReadFromStdin  s    

z!CommandLineTest.testReadFromStdinc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz!        s =   "foo\nbar"
        z        s = "foo\nbar"
        r”   r   r   r   r   Ú#testReadFromStdinWithEscapedStrings  s    

z3CommandLineTest.testReadFromStdinWithEscapedStringsc                 C   s*   t  d¡}t  d¡}| j||dgd d S )Nú6        def foo(): # trail
            x = 37
        z5        def foo():  # trail
          x = 37
        z--style=yapf©rr   r”   r   r   r   r   ÚtestSetYapfStyle  s    

ýz CommandLineTest.testSetYapfStylec                 C   sh   t  d¡}t  d¡}t  d¡}t | j|¡(}| j||d |¡gd W d   ƒ n1 sZ0    Y  d S )Nr—   z7        def foo():    # trail
          x = 37
        zX        [style]
        based_on_style = yapf
        spaces_before_comment = 4
        ú--style={0}r˜   ©r   r   r   r5   r'   rv   Úformat©r   r   r   Z
style_fileÚ	stylepathr   r   r   ÚtestSetCustomStyleBasedOnYapf)  s    



ýz-CommandLineTest.testSetCustomStyleBasedOnYapfc                 C   sh   t  d¡}t  d¡}t  d¡}t | j|¡(}| j||d |¡gd W d   ƒ n1 sZ0    Y  d S )Nzt        a_very_long_statement_that_extends_way_beyond # Comment
        short # This is a shorter statement
        zœ        a_very_long_statement_that_extends_way_beyond # Comment
        short                                         # This is a shorter statement
        z?        [style]
        spaces_before_comment = 15, 20
        rš   r˜   r›   r   r   r   r   Ú%testSetCustomStyleSpacesBeforeComment=  s    



ýz5CommandLineTest.testSetCustomStyleSpacesBeforeCommentc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz        if True: pass
        r”   r   r   r   r   ÚtestReadSingleLineCodeFromStdinP  s    

z/CommandLineTest.testReadSingleLineCodeFromStdinc                 C   sÄ   t  d¡}tjd| jd–\}}tj| j|dd`}ztjtd|g |d W n4 tj	y‚ } z|  
|jd¡ W Y d }~n
d }~0 0 W d   ƒ n1 s˜0    Y  W d   ƒ n1 s¶0    Y  d S )Nzp        '''The module docstring.'''
        # -*- coding: utf-8 -*-
        def f():
            x = 37
        ry   )r{   Údirnamerz   z--diff)rd   r@   )r   r   r   ÚNamedTempFiler'   r5   rk   Ú
check_callrj   ÚCalledProcessErrorrJ   Ú
returncode)r   r   Úoutr   r7   Úer   r   r   ÚtestEncodingVerificationY  s    
ÿÿz(CommandLineTest.testEncodingVerificationc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nav          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass
        aŠ          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass
        ú--linesú1-2r˜   r”   r   r   r   r   ÚtestReformattingSpecificLinesk  s    


ýz-CommandLineTest.testReformattingSpecificLinesc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nzx        import sys

        # Comment
        def some_func(x):
            x = ["badly" , "formatted","line" ]
        zw        import sys

        # Comment
        def some_func(x):
            x = ["badly", "formatted", "line"]
        rª   z5-5r˜   r”   r   r   r   r   Ú4testOmitFormattingLinesBeforeDisabledFunctionComment‰  s    

ýzDCommandLineTest.testOmitFormattingLinesBeforeDisabledFunctionCommentc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na¤          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        # yapf: disable
        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass
        # yapf: enable
        a¹          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        # yapf: disable
        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass
        # yapf: enable
        r”   r   r   r   r   ÚtestReformattingSkippingLines  s    

z-CommandLineTest.testReformattingSkippingLinesc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Naš          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        # yapf: disable
        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def f():
            def e():
                while (xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa' and
                       xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) ==
                       'bbbbbbb'):
                    pass
        a¯          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        # yapf: disable
        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def f():
            def e():
                while (xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa' and
                       xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) ==
                       'bbbbbbb'):
                    pass
        r”   r   r   r   r   Ú#testReformattingSkippingToEndOfFile¸  s    

z3CommandLineTest.testReformattingSkippingToEndOfFilec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na†          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):  # yapf: disable
                pass
        a›          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):  # yapf: disable
                pass
        r”   r   r   r   r   Ú"testReformattingSkippingSingleLineß  s    
	
z2CommandLineTest.testReformattingSkippingSingleLinec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz`        A = set([
            'hello',
            'world',
        ])  # yapf: disable
        r”   r   r   r   r   ÚtestDisableWholeDataStructureö  s    

z-CommandLineTest.testDisableWholeDataStructurec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nzª        class SplitPenaltyTest(unittest.TestCase):

          def testUnbreakable(self):
            self._CheckPenalties(tree, [
            ])  # yapf: disable
        z´        class SplitPenaltyTest(unittest.TestCase):

            def testUnbreakable(self):
                self._CheckPenalties(tree, [
                ])  # yapf: disable
        r”   r   r   r   r   Ú testDisableButAdjustIndentations  s    

z0CommandLineTest.testDisableButAdjustIndentationsc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na—          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def g():
            if (xxxxxxxxxxxx.yyyyyyyy        (zzzzzzzzzzzzz  [0]) ==     'aaaaaaaaaaa' and    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):  # yapf: disable
                pass
        a¬          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


        def g():
            if (xxxxxxxxxxxx.yyyyyyyy        (zzzzzzzzzzzzz  [0]) ==     'aaaaaaaaaaa' and    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):  # yapf: disable
                pass
        r”   r   r   r   r   Ú!testRetainingHorizontalWhitespace  s    
	
z1CommandLineTest.testRetainingHorizontalWhitespacec                 C   sr   t  d¡}t  d¡}| j||ddgd t  d¡}t  d¡}| j||g d¢d t  d	¡}| j||dd
gd d S )Nax          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def g():


            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):

                pass
        aŒ          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and
                    xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

        def g():


            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):

                pass
        rª   r«   r˜   z—

        if a:     b


        if c:
            to_much      + indent

            same



        #comment

        #   trailing whitespace
        z‘        if a: b


        if c:
            to_much      + indent

            same



        #comment

        #   trailing whitespace
        )rª   z3-3rª   z13-13zH        '''
        docstring

        '''

        import blah
        z2-2r”   r   r   r   r   ÚtestRetainingVerticalWhitespace-  s$    

ý

ý
	
ÿz/CommandLineTest.testRetainingVerticalWhitespacec                 C   s    d}d}| j ||ddgd d S )Nz# \
# \
# \

x = {
}
rª   ú1-1r˜   ©rv   r   r   r   r   Ú5testVerticalSpacingWithCommentWithContinuationMarkers}  s    ýzECommandLineTest.testVerticalSpacingWithCommentWithContinuationMarkersc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nz…        a = line_to_format
        def f():
            x = y + 42; z = n * 42
            if True: a += 1 ; b += 1 ; c += 1
        rª   rµ   r˜   r”   r   r   r   r   Ú*testRetainingSemicolonsWhenSpecifyingLines“  s    

ýz:CommandLineTest.testRetainingSemicolonsWhenSpecifyingLinesc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Naf          foo=42
        def f():
            email_text += """<html>This is a really long docstring that goes over the column limit and is multi-line.<br><br>
        <b>Czar: </b>"""+despot["Nicholas"]+"""<br>
        <b>Minion: </b>"""+serf["Dmitri"]+"""<br>
        <b>Residence: </b>"""+palace["Winter"]+"""<br>
        </body>
        </html>"""
        ah          foo = 42
        def f():
            email_text += """<html>This is a really long docstring that goes over the column limit and is multi-line.<br><br>
        <b>Czar: </b>"""+despot["Nicholas"]+"""<br>
        <b>Minion: </b>"""+serf["Dmitri"]+"""<br>
        <b>Residence: </b>"""+palace["Winter"]+"""<br>
        </body>
        </html>"""
        rª   rµ   r˜   r”   r   r   r   r   ÚtestDisabledMultilineStrings¥  s    



ýz,CommandLineTest.testDisabledMultilineStringsc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )NzÖ        # yapf: disable
        A = set([
            'hello',
            'world',
        ])
        # yapf: enable
        B = set([
            'hello',
            'world',
        ])  # yapf: disable
        rª   z1-10r˜   r”   r   r   r   r   ÚtestDisableWhenSpecifyingLines¿  s    

ýz.CommandLineTest.testDisableWhenSpecifyingLinesc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Na)          def horrible():
          oh_god()
          why_would_you()
          [
             'do',

              'that',
          ]

        def still_horrible():
            oh_god()
            why_would_you()
            [
                'do',

                'that'
            ]
        a          def horrible():
            oh_god()
            why_would_you()
            [
               'do',

                'that',
            ]

        def still_horrible():
            oh_god()
            why_would_you()
            ['do', 'that']
        rª   z14-15r˜   r”   r   r   r   r   Ú"testDisableFormattingInDataLiteralÝ  s    

ýz2CommandLineTest.testDisableFormattingInDataLiteralc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Ná’          class A(object):
            def aaaaaaaaaaaaa(self):
                c = bbbbbbbbb.ccccccccc('challenge', 0, 1, 10)
                self.assertEqual(
                    ('ddddddddddddddddddddddddd',
             'eeeeeeeeeeeeeeeeeeeeeeeee.%s' %
                     c.ffffffffffff),
             gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                iiiii = jjjjjjjjjjjjjj.iiiii
        á‘          class A(object):
            def aaaaaaaaaaaaa(self):
                c = bbbbbbbbb.ccccccccc('challenge', 0, 1, 10)
                self.assertEqual(('ddddddddddddddddddddddddd',
                                  'eeeeeeeeeeeeeeeeeeeeeeeee.%s' % c.ffffffffffff),
                                 gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                iiiii = jjjjjjjjjjjjjj.iiiii
        rª   z4-7r˜   r”   r   r   r   r   Ú:testRetainVerticalFormattingBetweenDisabledAndEnabledLines  s    

	ýzJCommandLineTest.testRetainVerticalFormattingBetweenDisabledAndEnabledLinesc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nzœ        class A(object):
            def aaaaaaaaaaaaa(self):
                pass


            def bbbbbbbbbbbbb(self):  # 5
                pass
        rª   z4-4r˜   r”   r   r   r   r   Ú0testRetainVerticalFormattingBetweenDisabledLines  s    
	
	ýz@CommandLineTest.testRetainVerticalFormattingBetweenDisabledLinesc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nr¼   r½   rª   z5-6r˜   r”   r   r   r   r   Ú,testFormatLinesSpecifiedInMiddleOfExpression7  s    

	ýz<CommandLineTest.testFormatLinesSpecifiedInMiddleOfExpressionc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )NzÇ        def foo():
            '''First line.
            Second line.
            '''  # comment
            x = '''hello world'''  # second comment
            return 42  # another comment
        rª   rµ   r˜   r”   r   r   r   r   Ú#testCommentFollowingMultilineStringQ  s    

ýz3CommandLineTest.testCommentFollowingMultilineStringc                 C   sP   t  d¡}t  d¡}| j||dgd t  d¡}t  d¡}| j||dgd d S )Nz†      def overly_long_function_name(first_argument_on_the_same_line,
      second_argument_makes_the_line_too_long):
        pass
    z¦      def overly_long_function_name(first_argument_on_the_same_line,
                                    second_argument_makes_the_line_too_long):
          pass
    z--style=pep8r˜   z‘      def overly_long_function_name(
        first_argument_on_the_same_line,
        second_argument_makes_the_line_too_long):
        pass
    z”      def overly_long_function_name(
          first_argument_on_the_same_line, second_argument_makes_the_line_too_long
      ):
          pass
    z--style=facebookr”   )r   r   r   Zexpected_formatted_fb_coder   r   r   ÚtestDedentClosingBracketg  s    

ý

ýz(CommandLineTest.testDedentClosingBracketc                 C   s|   t  d¡}t  d¡}tj| jddD\}}| t  d¡¡ | ¡  | j||d |¡gd W d   ƒ n1 sn0    Y  d S )Nz´       some_long_function_name_foo(
           {
               'first_argument_of_the_thing': id,
               'second_argument_of_the_thing': "some thing"
           }
       )zœ       some_long_function_name_foo({
           'first_argument_of_the_thing': id,
           'second_argument_of_the_thing': "some thing"
       })
       Úw)r¢   r€   zY          [style]
          column_limit=82
          coalesce_brackets = True
          rš   r˜   )	r   r   r   r£   r'   ÚwriteÚflushrv   rœ   )r   r   r   ÚfÚnamer   r   r   ÚtestCoalesceBrackets  s    

ÿ
ýz$CommandLineTest.testCoalesceBracketsc                 C   s,   t  d¡}t  d¡}| j||g d¢d d S )Nzs        def   foo():
          def bar():
            return {msg_id: author for author, msg_id in reader}
        zq        def foo():
          def bar():
            return {msg_id: author for author, msg_id in reader}
        ©rª   rµ   ú--styler	   r˜   r”   r   r   r   r   ÚtestPseudoParenSpaces¸  s    

ýz%CommandLineTest.testPseudoParenSpacesc                 C   s,   t  d¡}t  d¡}| j||g d¢d d S )Na“          # This is a comment
        FOO = {
            aaaaaaaa.ZZZ: [
                bbbbbbbbbb.Pop(),
                # Multiline comment.
                # Line two.
                bbbbbbbbbb.Pop(),
            ],
            'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
                ('yyyyy', zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz),
            '#': lambda x: x  # do nothing
        }
        rÉ   r˜   r”   r   r   r   r   Ú&testMultilineCommentFormattingDisabledÈ  s    

ýz6CommandLineTest.testMultilineCommentFormattingDisabledc                 C   s,   t  d¡}t  d¡}| j||g d¢d d S )Nzh        import os

        SCOPES = [
            'hello world'  # This is a comment.
        ]
        rÉ   r˜   r”   r   r   r   r   Ú*testTrailingCommentsWithDisabledFormattingê  s    

ýz:CommandLineTest.testTrailingCommentsWithDisabledFormattingc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )Nz%def foo_function():
 if True:
  pass
z%def foo_function():
	if True:
		pass
ú=[style]
based_on_style = yapf
USE_TABS = true
INDENT_WIDTH=1
rš   r˜   ©r   r5   r'   rv   rœ   ©r   r   r   Zstyle_contentsrž   r   r   r   ÚtestUseTabsþ  s    
ýzCommandLineTest.testUseTabsc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )Nz&def f():
  return ['hello', 'world',]
z2def f():
	return [
	    'hello',
	    'world',
	]
rÎ   rš   r˜   rÏ   rÐ   r   r   r   ÚtestUseTabsWith  s    
ýzCommandLineTest.testUseTabsWithc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )NúAdef foo_function(arg1, arg2, arg3):
  return ['hello', 'world',]
zLdef foo_function(
		arg1, arg2, arg3):
	return [
			'hello',
			'world',
	]
zŠ[style]
based_on_style = yapf
USE_TABS = true
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = fixed
rš   r˜   rÏ   rÐ   r   r   r   Ú&testUseTabsContinuationAlignStyleFixed-  s    	
ýz6CommandLineTest.testUseTabsContinuationAlignStyleFixedc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )NrÓ   zNdef foo_function(arg1, arg2,
					arg3):
	return [
			'hello',
			'world',
	]
z‘[style]
based_on_style = yapf
USE_TABS = true
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = valign-right
rš   r˜   rÏ   rÐ   r   r   r   Ú,testUseTabsContinuationAlignStyleVAlignRightI  s    	
ýz<CommandLineTest.testUseTabsContinuationAlignStyleVAlignRightc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )NrÓ   zjdef foo_function(
        arg1, arg2, arg3):
    return [
            'hello',
            'world',
    ]
zz[style]
based_on_style = yapf
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = fixed
rš   r˜   rÏ   rÐ   r   r   r   Ú(testUseSpacesContinuationAlignStyleFixede  s    
ýz8CommandLineTest.testUseSpacesContinuationAlignStyleFixedc                 C   sV   d}d}d}t  | j|¡(}| j||d |¡gd W d   ƒ n1 sH0    Y  d S )NrÓ   zudef foo_function(arg1, arg2,
                    arg3):
    return [
            'hello',
            'world',
    ]
z[style]
based_on_style = yapf
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = valign-right
rš   r˜   rÏ   rÐ   r   r   r   Ú.testUseSpacesContinuationAlignStyleVAlignRight€  s    
ýz>CommandLineTest.testUseSpacesContinuationAlignStyleVAlignRightc                 C   s–   t  d¡}t  d¡}tj| jd`\}}tjtdg |tjtjd}| 	¡ \}}|  
|d¡ | j||d |¡gd W d   ƒ n1 sˆ0    Y  d S )	Nz3        def foo_function():
          pass
        z5        def foo_function():
            pass
        )r¢   z--style-help)rd   re   rf   rh   rš   r˜   )r   r   r   r£   r'   rk   rl   rj   rm   rn   rJ   rv   rœ   )r   r   r   Z	stylefilerž   rs   r   ru   r   r   r   ÚtestStyleOutputRoundTrip›  s"    

ü
ýz(CommandLineTest.testStyleOutputRoundTripc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nzq        A = 42


        # A comment
        def x():
            pass
        def _():
            pass
        rª   r«   r˜   r”   r   r   r   r   ÚtestSpacingBeforeComments³  s    



ýz)CommandLineTest.testSpacingBeforeCommentsc                 C   s,   t  d¡}t  d¡}| j||g d¢d d S )Na5          A=42

        X = {
            # 'Valid' statuses.
            PASSED:  # Passed
                'PASSED',
            FAILED:  # Failed
                'FAILED',
            TIMED_OUT:  # Timed out.
                'FAILED',
            BORKED:  # Broken.
                'BROKEN'
        }
        a7          A = 42

        X = {
            # 'Valid' statuses.
            PASSED:  # Passed
                'PASSED',
            FAILED:  # Failed
                'FAILED',
            TIMED_OUT:  # Timed out.
                'FAILED',
            BORKED:  # Broken.
                'BROKEN'
        }
        )rÊ   r	   rª   rµ   r˜   r”   r   r   r   r   Ú testSpacingBeforeCommentsInDictsÍ  s    

ýz0CommandLineTest.testSpacingBeforeCommentsInDictsc                 C   s,   t  d¡}t  d¡}| j||ddgd d S )Nzµ        # yapf_lines_bug.py
        # yapf: disable
        def outer_func():
            def inner_func():
                return
            return
        # yapf: enable
        rª   z1-8r˜   r”   r   r   r   r   ÚtestDisableWithLinesOptionñ  s    
	
	ýz*CommandLineTest.testDisableWithLinesOptionc                 C   s    d}d}| j ||g d¢d d S )Nz-# yapf: disable
a = [
    1,
    2,

    3
]
)rÊ   r	   rª   z1-100r˜   r¶   r   r   r   r   ÚtestDisableWithLineRanges	  s    		ýz)CommandLineTest.testDisableWithLineRanges)NN)7r   r    r!   Ú__doc__Úclassmethodrb   rc   rv   r†   r‹   rŒ   r   rŽ   r“   r•   r–   r™   rŸ   r    r¡   r©   r¬   r­   r®   r¯   r°   r±   r²   r³   r´   r·   r¸   r¹   rº   r»   r¾   r¿   rÀ   rÁ   rÂ   rÈ   rË   rÌ   rÍ   rÑ   rÒ   rÔ   rÕ   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   r   r   r   r   r_   –  sn   

  ü

		'P(6"$r_   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚBadInputTestz,Test yapf's behaviour when passed bad input.c                 C   s   d}|   tjtj|¡ d S )Nz  a = 1
©rM   r   Z	YapfErrorr   r   ©r   r0   r   r   r   ÚtestBadSyntax%  s    zBadInputTest.testBadSyntaxc                 C   s   d}|   tjtj|¡ d S )Nzx = """hello
rà   rá   r   r   r   ÚtestBadCode)  s    zBadInputTest.testBadCodeN)r   r    r!   rÝ   râ   rã   r   r   r   r   rß   "  s   rß   c                   @   s(   e Zd Zedd„ ƒZdd„ Zdd„ ZdS )ÚDiffIndentTestc                  C   s   t  ¡ } d| d< d| d< | S )NrC   ZINDENT_WIDTHZCONTINUATION_INDENT_WIDTH©r   ZCreatePEP8Style©Zmy_styler   r   r   Ú	_OwnStyle0  s    zDiffIndentTest._OwnStylec                 C   s,   t j|t |  ¡ ¡d\}}|  ||¡ d S ©Nr   ©r   r   r   ÚSetGlobalStylerç   rJ   r   r   r   r   r   7  s    ÿ
zDiffIndentTest._Checkc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz:        for i in range(5):
         print('bar')
         z>        for i in range(5):
           print('bar')
           r   r   r   r   r   r   <  s    

zDiffIndentTest.testSimpleN)r   r    r!   Ústaticmethodrç   r   r   r   r   r   r   rä   .  s   
rä   c                   @   sx   e Zd Zedd„ ƒZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )Ú'HorizontallyAlignedTrailingCommentsTestc                  C   s   t  ¡ } g d¢| d< | S )N)é   é   é#   ZSPACES_BEFORE_COMMENTrå   ræ   r   r   r   rç   J  s    z1HorizontallyAlignedTrailingCommentsTest._OwnStylec                 C   s,   t j|t |  ¡ ¡d\}}|  ||¡ d S rè   )r   r   r   rê   rç   r   r   r   r   r   r   T  s    ÿ
z.HorizontallyAlignedTrailingCommentsTest._Checkc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nzû        foo = '1' # Aligned at first list value

        foo = '2__<15>' # Aligned at second list value

        foo = '3____________<25>' # Aligned at third list value

        foo = '4______________________<35>' # Aligned beyond list values
        a          foo = '1'     # Aligned at first list value

        foo = '2__<15>'         # Aligned at second list value

        foo = '3____________<25>'         # Aligned at third list value

        foo = '4______________________<35>' # Aligned beyond list values
        r   r   r   r   r   r   Y  s    
	
	z2HorizontallyAlignedTrailingCommentsTest.testSimplec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nzî        func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                            # Line 5
                                            # Line 6
        zÂ        func(1)       # Line 1
        func(2)       # Line 2
                      # Line 3
        func(3)       # Line 4
                      # Line 5
                      # Line 6
        r   r   r   r   r   Ú	testBlockn  s    

z1HorizontallyAlignedTrailingCommentsTest.testBlockc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na          func(1)     # Line 1
        func___________________(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                            # Line 5
                                            # Line 6
        a:          func(1)                           # Line 1
        func___________________(2)        # Line 2
                                          # Line 3
        func(3)                           # Line 4
                                          # Line 5
                                          # Line 6
        r   r   r   r   r   ÚtestBlockWithLongLine  s    

z=HorizontallyAlignedTrailingCommentsTest.testBlockWithLongLinec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na          func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                        # Line 5
                                    # Line 6

        def Func():
            pass
        zé        func(1)       # Line 1
        func(2)       # Line 2
                      # Line 3
        func(3)       # Line 4
                      # Line 5
                      # Line 6


        def Func():
            pass
        r   r   r   r   r   ÚtestBlockFuncSuffix”  s    

z;HorizontallyAlignedTrailingCommentsTest.testBlockFuncSuffixc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nah          func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                        # Line 5 - SpliceComments makes this part of the previous block
                                    # Line 6

                                            # Aligned with prev comment block
        a2          func(1)       # Line 1
        func(2)       # Line 2
                      # Line 3
        func(3)       # Line 4
                      # Line 5 - SpliceComments makes this part of the previous block
                      # Line 6

                      # Aligned with prev comment block
        r   r   r   r   r   ÚtestBlockCommentSuffix®  s    



z>HorizontallyAlignedTrailingCommentsTest.testBlockCommentSuffixc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na²          if True:
            func(1)     # Line 1
            func(2) # Line 2
            # Line 3
            func(3)                             # Line 4
                                                # Line 5 - SpliceComments makes this a new block
                                                # Line 6

                                                # Aligned with Func

            def Func():
                pass
        a8          if True:
            func(1)   # Line 1
            func(2)   # Line 2
                      # Line 3
            func(3)   # Line 4

            # Line 5 - SpliceComments makes this a new block
            # Line 6

            # Aligned with Func


            def Func():
                pass
        r   r   r   r   r   ÚtestBlockIndentedFuncSuffixÅ  s    

zCHorizontallyAlignedTrailingCommentsTest.testBlockIndentedFuncSuffixc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )NaV          if True:
            func(1)     # Line 1
            func(2) # Line 2
            # Line 3
            func(3)                             # Line 4
                                                # Line 5
                                                # Line 6

                                                # Not aligned
        zî        if True:
            func(1)   # Line 1
            func(2)   # Line 2
                      # Line 3
            func(3)   # Line 4
                      # Line 5
                      # Line 6

            # Not aligned
        r   r   r   r   r   ÚtestBlockIndentedCommentSuffixæ  s    

zFHorizontallyAlignedTrailingCommentsTest.testBlockIndentedCommentSuffixc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na¼          if True:
            if True:
                if True:
                    func(1)     # Line 1
                    func(2) # Line 2
                    # Line 3
                    func(3)                             # Line 4
                                                        # Line 5
                                                        # Line 6

                                                        # Not aligned
        a`          if True:
            if True:
                if True:
                    func(1)     # Line 1
                    func(2)     # Line 2
                                # Line 3
                    func(3)     # Line 4
                                # Line 5
                                # Line 6

                    # Not aligned
        r   r   r   r   r   ÚtestBlockMultiIndentedÿ  s    

z>HorizontallyAlignedTrailingCommentsTest.testBlockMultiIndentedc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )NzÜ        def MyFunc(
            arg1,   # Desc 1
            arg2,   # Desc 2
            a_longer_var_name,  # Desc 3
            arg4,
            arg5,   # Desc 5
            arg6,
        ):
            pass
        a           def MyFunc(
            arg1,               # Desc 1
            arg2,               # Desc 2
            a_longer_var_name,  # Desc 3
            arg4,
            arg5,               # Desc 5
            arg6,
        ):
            pass
        r   r   r   r   r   ÚtestArgs  s    

z0HorizontallyAlignedTrailingCommentsTest.testArgsc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )NzË        a() # comment 1
        b() # comment 2

        # yapf: disable
        c() # comment 3
        d()   # comment 4
        # yapf: enable

        e() # comment 5
        f() # comment 6
        zó        a()           # comment 1
        b()           # comment 2

        # yapf: disable
        c() # comment 3
        d()   # comment 4
        # yapf: enable

        e()           # comment 5
        f()           # comment 6
        r   r   r   r   r   ÚtestDisableBlock5  s    

z8HorizontallyAlignedTrailingCommentsTest.testDisableBlockc                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Nz—        short # comment 1
        do_not_touch1 # yapf: disable
        do_not_touch2   # yapf: disable
        a_longer_statement # comment 2
        z®        short                   # comment 1
        do_not_touch1 # yapf: disable
        do_not_touch2   # yapf: disable
        a_longer_statement      # comment 2
        r   r   r   r   r   ÚtestDisabledLineP  s    

z8HorizontallyAlignedTrailingCommentsTest.testDisabledLineN)r   r    r!   rë   rç   r   r   rð   rñ   rò   ró   rô   rõ   rö   r÷   rø   rù   r   r   r   r   rì   H  s   
	!rì   c                   @   s(   e Zd Zedd„ ƒZdd„ Zdd„ ZdS )Ú"_SpacesAroundDictListTupleTestImplc                  C   s$   t  ¡ } d| d< d| d< d| d< | S )NTZDISABLE_ENDING_COMMA_HEURISTICFZ SPLIT_ALL_COMMA_SEPARATED_VALUESZ%SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATEDrå   ræ   r   r   r   rç   b  s
    z,_SpacesAroundDictListTupleTestImpl._OwnStylec                 C   s,   t j|t |  ¡ ¡d\}}|  ||¡ d S rè   ré   r   r   r   r   r   j  s    ÿ
z)_SpacesAroundDictListTupleTestImpl._Checkc                 C   s
   d | _ d S r#   )ZmaxDiffr(   r   r   r   r)   o  s    z(_SpacesAroundDictListTupleTestImpl.setUpN)r   r    r!   rë   rç   r   r)   r   r   r   r   rú   `  s   
rú   c                       s(   e Zd Ze‡ fdd„ƒZdd„ Z‡  ZS )ÚSpacesAroundDictTestc                    s   t t| ƒ ¡ }d|d< |S )NTZSPACES_AROUND_DICT_DELIMITERS)Úsuperrû   rç   ©ra   r   ©Ú	__class__r   r   rç   u  s    zSpacesAroundDictTest._OwnStylec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na?        {1 : 2}
      {k:v for k, v in other.items()}
      {k for k in [1, 2, 3]}

      # The following statements should not change
      {}
      {1 : 2} # yapf: disable

      # yapf: disable
      {1 : 2}
      # yapf: enable

      # Dict settings should not impact lists or tuples
      [1, 2]
      (3, 4)
      aE        { 1: 2 }
      { k: v for k, v in other.items() }
      { k for k in [1, 2, 3] }

      # The following statements should not change
      {}
      {1 : 2} # yapf: disable

      # yapf: disable
      {1 : 2}
      # yapf: enable

      # Dict settings should not impact lists or tuples
      [1, 2]
      (3, 4)
      r   r   r   r   r   ÚtestStandard|  s    

z!SpacesAroundDictTest.testStandard©r   r    r!   rÞ   rç   r   Ú__classcell__r   r   rþ   r   rû   s  s   rû   c                       s(   e Zd Ze‡ fdd„ƒZdd„ Z‡  ZS )ÚSpacesAroundListTestc                    s   t t| ƒ ¡ }d|d< |S )NTZSPACES_AROUND_LIST_DELIMITERS)rü   r  rç   rý   rþ   r   r   rç   ¥  s    zSpacesAroundListTest._OwnStylec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na†        [a,b,c]
      [4,5,]
      [6, [7, 8], 9]
      [v for v in [1,2,3] if v & 1]

      # The following statements should not change
      index[0]
      index[a, b]
      []
      [v for v in [1,2,3] if v & 1] # yapf: disable

      # yapf: disable
      [a,b,c]
      [4,5,]
      # yapf: enable

      # List settings should not impact dicts or tuples
      {a: b}
      (1, 2)
      a—        [ a, b, c ]
      [ 4, 5, ]
      [ 6, [ 7, 8 ], 9 ]
      [ v for v in [ 1, 2, 3 ] if v & 1 ]

      # The following statements should not change
      index[0]
      index[a, b]
      []
      [v for v in [1,2,3] if v & 1] # yapf: disable

      # yapf: disable
      [a,b,c]
      [4,5,]
      # yapf: enable

      # List settings should not impact dicts or tuples
      {a: b}
      (1, 2)
      r   r   r   r   r   r   ¬  s    

z!SpacesAroundListTest.testStandardr  r   r   rþ   r   r  £  s   r  c                       s(   e Zd Ze‡ fdd„ƒZdd„ Z‡  ZS )ÚSpacesAroundTupleTestc                    s   t t| ƒ ¡ }d|d< |S )NTZSPACES_AROUND_TUPLE_DELIMITERS)rü   r  rç   rý   rþ   r   r   rç   Ý  s    zSpacesAroundTupleTest._OwnStylec                 C   s$   t  d¡}t  d¡}|  ||¡ d S )Na‘        (0, 1)
      (2, 3)
      (4, 5, 6,)
      func((7, 8), 9)

      # The following statements should not change
      func(1, 2)
      (this_func or that_func)(3, 4)
      if (True and False): pass
      ()

      (0, 1) # yapf: disable

      # yapf: disable
      (0, 1)
      (2, 3)
      # yapf: enable

      # Tuple settings should not impact dicts or lists
      {a: b}
      [3, 4]
      a™        ( 0, 1 )
      ( 2, 3 )
      ( 4, 5, 6, )
      func(( 7, 8 ), 9)

      # The following statements should not change
      func(1, 2)
      (this_func or that_func)(3, 4)
      if (True and False): pass
      ()

      (0, 1) # yapf: disable

      # yapf: disable
      (0, 1)
      (2, 3)
      # yapf: enable

      # Tuple settings should not impact dicts or lists
      {a: b}
      [3, 4]
      r   r   r   r   r   r   ä  s    

z"SpacesAroundTupleTest.testStandardr  r   r   rþ   r   r  Û  s   r  Ú__main__))rÝ   r„   ÚloggingÚosr+   rk   Úsysr%   r   Zunittestr   Z yapf_third_party._ylib2to3.pgen2r   Zyapf.yapflibr   r   r   Z	yapftestsr   r   Úpathr¢   ÚabspathÚ__file__ZROOT_DIRÚ
executablerj   ZYAPFTestr
   ZTestCaser"   r_   rß   rä   rì   rú   rû   r  r  r   Úmainr   r   r   r   Ú<module>   sV     U           08<
