
    `N`<                        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 ej                            ej                            ej                            e                              Zej        d	d
ddgZ G d dej                  Z G d de	j                  Z G d de	j                  Z G d de	j                  Z G d de	j                  Z  G d dej                  Z! G d de	j                  Z" G d de"          Z# G d de"          Z$ G d d e"          Z%e&d!k    r e	j'                     dS dS )"zTests for yapf.yapf.    N)tokenize)	py3compat)style)yapf_api)utils)yapf_test_helperz-myapfz--verifyz--no-local-stylec                   &    e Zd Zd Zd Zd Zd ZdS )FormatCodeTestc                 d    t          j        |d          \  }}|                     ||           d S )Nr	   style_config)r   
FormatCodeassertCodeEqualselfunformatted_codeexpected_formatted_codeformatted_code_s        3lib/python3.11/site-packages/yapftests/yapf_test.py_CheckzFormatCodeTest._Check,   s@     +v/ / /NA0.AAAAA    c                 Z    t          j        d          }|                     ||           d S )Nz        print('foo')
        textwrapdedentr   )r   r   s     r   
testSimplezFormatCodeTest.testSimple1   s7     (   	KK "233333r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nz        if True:
          pass(        if True:
          pass
        r   r   r   r   s      r   testNoEndingNewlinez"FormatCodeTest.testNoEndingNewline7   sP     (   'o /   	KK "9:::::r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nza.print
r   r!   s      r   testPrintAfterPeriodz#FormatCodeTest.testPrintAfterPeriodA   s>    77&oo>>KK "9:::::r   N)__name__
__module____qualname__r   r   r"   r$    r   r   r   r   *   sS        B B B
4 4 4; ; ;; ; ; ; ;r   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )FormatFileTestc                 6    t          j                    | _        d S Ntempfilemkdtemptest_tmpdirr   s    r   setUpzFormatFileTest.setUpI   s    '))Dr   c                 8    t          j        | j                   d S r,   shutilrmtreer0   r1   s    r   tearDownzFormatFileTest.tearDownL   s    
M$"#####r   c                     ||k    rwd}|dz  }|d                     |                                          z  }|dz  }|d                     |                                          z  }|                     |           d S d S )NzCode format mismatch:
zExpected:
 >z
 > z
Actual:
 >)join
splitlinesfail)r   expected_codecodemsgs       r   r   zFormatFileTest.assertCodeEqualO   s    }%c	_c	W\\-2244555c	_c	W\\$//++,,,c
iinnnnn r   c                    t          j        d          }t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )N'        if True:
         pass
        z*        if True:
            pass
        r    pep8r   r	   r   r   r   TempFileContentsr0   r   
FormatFiler   )r   r   expected_formatted_code_pep8expected_formatted_code_yapffilepathr   r   s          r   testFormatFilezFormatFileTest.testFormatFileY   s>    (   $,? 4 $ $  $,? 4 $ $  
	 02B	C	C Ix%0OOOna
7HHH%0OOOna
7HHHI I I I I I I I I I I I I I I I I Is   A!CC	C	c                    t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   r   rB   r   r   r   rG   r   r   s         r   testDisableLinesPatternz&FormatFileTest.testDisableLinesPatternm   s     (   'o /   
	 02B	C	C Dx%0OOOna
2NCCCD D D D D D D D D D D D D D D D D D   1BBBc                    t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   r   rB   rJ   s         r   "testDisableAndReenableLinesPatternz1FormatFileTest.testDisableAndReenableLinesPattern   s     (   'o /   
	 02B	C	C Dx%0OOOna
2NCCCD D D D D D D D D D D D D D D D D DrL   c                    t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            n# 1 swxY w Y   t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   r   z      def foo_function():
          # some comment
          # yapf: disable

          foo(
          bar,
          baz
          )

          # yapf: enable
      rB   )r   r   r   rG   r   r   r=   s          r   !testDisablePartOfMultilineCommentz0FormatFileTest.testDisablePartOfMultilineComment   s    
( 
 
 'o 
/ 
 
 
	 02B	C	C Dx%0OOOna
2NCCCD D D D D D D D D D D D D D D ? 
  D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s$   1B  BB91C77C;>C;c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Nav          # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        rA   r   rB   r   r=   rG   r   r   s        r   testEnabledDisabledSameCommentz-FormatFileTest.testEnabledDisabledSameComment   s    ?   D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   1A--A14A1c                    t          j        d          }t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |ddg          \  }}}|                     ||           t          j        |ddg          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   )      )r   lines)   rY   rB   )r   r   "expected_formatted_code_lines1and2expected_formatted_code_lines3rG   r   r   s          r   testFormatFileLinesSelectionz+FormatFileTest.testFormatFileLinesSelection   sT    (   *2 : * *& &._ 6 & &" 
	 02B	C	C Kx%0
x9 9 9na
=~NNN%0
x9 9 9na
9>JJJK K K K K K K K K K K K K K K K K Ks   A%C		CCc                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     d|           d d d            d S # 1 swxY w Y   d S )Nr@   T)
print_diffz+  pass)r   r   r   rC   r0   r   rD   assertIn)r   r   rG   diffr   s        r   testFormatFileDiffz!FormatFileTest.testFormatFileDiff   s     (   
	 02B	C	C &x&xDAAAjdAq
mmJ%%%& & & & & & & & & & & & & & & & & &rT   c                 h   d}d}t          j        | j        |          5 }t          j        |d          \  }}}|                     |d            t          |          5 }t          j        d         dk    r<| 	                    ||
                                                    d                     n(| 	                    ||
                                           d d d            n# 1 swxY w Y   |                     t          t          j        |dd           d d d            d S # 1 swxY w Y   d S )	NzTrue==False
zTrue == False
T)in_placer   rW   ascii)rc   r^   )r   rC   r0   r   rD   assertEqualopensysversion_infor   readdecodeassertRaises
ValueError)r   r   r   rG   resultr   fds          r   testFormatFileInPlacez$FormatFileTest.testFormatFileInPlace   s   ''N		 02B	C	C x(DAAAlfa
vt$$$>> :RA!##


~rwwyy/?/?/H/H
I
I
I
I


~rwwyy
9
9
9	: : : : : : : : : : : : : : : 



                     s7   A D'A;C&D'&C*	*D'-C*	.,D''D+.D+c                 P   t          j                    }t          j        |          }t          j        d          }|                    |           |                     t          t          j	        d|j
                   |                     |                                d           d S )Nmyloggerznot_a_file.py)loggerz5[Errno 2] No such file or directory: 'not_a_file.py'
)r   StringIOloggingStreamHandler	getLogger
addHandlerrk   IOErrorr   rD   errorre   getvalue)r   streamhandlerrr   s       r   
testNoFilezFormatFileTest.testNoFile  s    !!F#F++Gz**F
g$ofl  L L LV__&&MO O O O Or   c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Nz        foo = [# A list of things
               # bork
            'one',
            # quark
            'two'] # yapf: disable
        rA   r   rB   rR   s        r   testCommentsUnformattedz&FormatFileTest.testCommentsUnformatted  s    ?   D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1rT   c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )NzP        # yapf: disable
        a = [
        1]
        # yapf: enable
        rA   r   rB   rR   s        r   )testDisabledHorizontalFormattingOnNewLinez8FormatFileTest.testDisabledHorizontalFormattingOnNewLine"  s    ?   D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1rT   c                    t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   r   rB   rJ   s         r    testSplittingSemicolonStatementsz/FormatFileTest.testSplittingSemicolonStatements-  s     (  
 'o /   
	 02B	C	C Dx%0OOOna
2NCCCD D D D D D D D D D D D D D D D D DrL   c                    t          j        d          }t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w 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
        rA   r   rB   rJ   s         r   testSemicolonStatementsDisabledz.FormatFileTest.testSemicolonStatementsDisabled@  s     (  
 'o /   
	 02B	C	C Dx%0OOOna
2NCCCD D D D D D D D D D D D D D D D D DrL   c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Nz7        # yapf: disable
        if True: a ; b
        rA   r   rB   rR   s        r   (testDisabledSemiColonSeparatedStatementsz7FormatFileTest.testDisabledSemiColonSeparatedStatementsR  s    ?   D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1rT   c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Nz        # yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   rB   rR   s        r   'testDisabledMultilineStringInDictionaryz6FormatFileTest.testDisabledMultilineStringInDictionary[      ?   D 
	 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1rT   c                     t          j        d          }t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Na          # TODO(fix formatting): yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   rB   rR   s        r   testDisabledWithPrecedingTextz,FormatFileTest.testDisabledWithPrecedingTextn  r   rT   c                     d}t          j        | j        |          5 }t          j        |d          \  }}}|                     ||           d d d            d S # 1 swxY w Y   d S )Nzclass _():
  pass
r	   r   )r   rC   r0   r   rD   r   rR   s        r   testCRLFLineEndingz!FormatFileTest.testCRLFLineEnding  s    &D		 0$	7	7 18%0OOOna
40001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   1AA"AN)r%   r&   r'   r2   r7   r   rH   rK   rN   rP   rS   r\   ra   ro   r}   r   r   r   r   r   r   r   r   r(   r   r   r*   r*   G   sV       * * *$ $ $  I I I(D D D*D D D.*1 *1 *1X1 1 1K K K<& & &  &O O O
1 
1 
1	1 	1 	1D D D&D D D$1 1 11 1 1&1 1 1&1 1 1 1 1r   r*   c                      e Zd ZdZed             Zed             Z	 	 d5dZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2 e3j4        e5j6        d1          d2             Z7 e3j4        e5j6        d1          d3             Z8d4 Z9dS )6CommandLineTestz1Test how calling yapf from the command line acts.c                 6    t          j                    | _        d S r,   r-   clss    r   
setUpClasszCommandLineTest.setUpClass  s    &((COOOr   c                 8    t          j        | j                   d S r,   r4   r   s    r   tearDownClasszCommandLineTest.tearDownClass  s    
M#/"""""r   Nc                 `   t           |pg z   }t          j        |t          j        t          j        t          j        |          }|                    |                    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-sigr   utf-8N)	YAPF_BINARY
subprocessPopenPIPEcommunicateencodere   assertMultiLineEqualrj   )	r   unformattedexpectedextra_optionsr   cmdlinepreformatted_code
stderrdatas	            r   assertYapfReformatsz#CommandLineTest.assertYapfReformats  s      ]0b1Go	 	 	A $%==;''$) $) jZ%%%.55g>>IIIIIr   c                 D   t          j        d          }t          j        | j        d          5 \  }}t          j        | j        |d          5 }t          j        t          d|gz   |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nu4           def foo():
            print('⇒')
        .py)dirnamesuffixr   --diffr   )	r   r   r   NamedTempFiler0   rC   r   
check_callr   )r   r   outr   rG   s        r   testUnicodeEncodingPipedToFilez.CommandLineTest.testUnicodeEncodingPipedToFile  sZ    (   
	 
0 
0 
0 N3;C!

,U< < < N?GkXx,@@MMMMN N N N N N N N N N N N N N NN N N N N N N N N N N N N N N N N Ns5    B!A=1B=B	BB	BBBc                    t          j        d          }t          j        d          }t          j        | j        |d          5 }t          j        t          d|gz             }|                                 t          j
        |dd          5 }|                                }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     ||           d S )	N,        def foo():
          x = 37
        .        def foo():
            x = 37
        r   r   
--in-placer )modenewline)r   r   r   rC   r0   r   r   r   waitiorf   ri   re   r   r   r   rG   r   rn   r   s          r   testInPlaceReformattingz'CommandLineTest.testInPlaceReformatting  sh    (   'o /   
	*5
: 
: 
: %=E

;,)AA
B
Baffhhh78#r222 %b7799% % % % % % % % % % % % % % %	% % % % % % % % % % % % % % % 	%'>?????s7   A
CB0$C0B4	4C7B4	8CCCc                    d}d}t          j        | j        |d          5 }t          j        t
          d|gz             }|                                 t          j        |ddd	          5 }|	                                }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | 
                    ||           d S )
Nz


r   r   r   r   r   r   r   encodingr   r   rC   r0   r   r   r   r   r   rf   ri   re   r   s          r   testInPlaceReformattingBlankz,CommandLineTest.testInPlaceReformattingBlank  sD   #		*5
: 
: 
: %=E

;,)AA
B
Baffhhh78#DDD %7799% % % % % % % % % % % % % % %	% % % % % % % % % % % % % % % 	%'>?????6   AB$,BB$B	B$B	B$$B(+B(c                    d}d}t          j        | j        |d          5 }t          j        t
          d|gz             }|                                 t          j        |ddd          5 }|	                                }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | 
                    ||           d S )Nr   r   r   r   r   r   r   r   r   s          r   testInPlaceReformattingEmptyz,CommandLineTest.testInPlaceReformattingEmpty  sD   !		*5
: 
: 
: %=E

;,)AA
B
Baffhhh78#DDD %7799% % % % % % % % % % % % % % %	% % % % % % % % % % % % % % % 	%'>?????r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nr   r   r   r   r   r!   s      r   testReadFromStdinz!CommandLineTest.testReadFromStdin  sR     (   'o /   	-/FGGGGGr   c                     t          j        d          }t          j        d          }|                     ||           d S )Nz!        s =   "foo\nbar"
        z        s = "foo\nbar"
        r   r!   s      r   #testReadFromStdinWithEscapedStringsz3CommandLineTest.testReadFromStdinWithEscapedStrings  R     (   'o /   	-/FGGGGGr   c                     t          j        d          }t          j        d          }|                     ||dg           d S )N6        def foo(): # trail
            x = 37
        z5        def foo():  # trail
          x = 37
        z--style=yapfr   r   r!   s      r   testSetYapfStylez CommandLineTest.testSetYapfStyle  sg     (   'o /   	%&  ( ( ( ( (r   c                 <   t          j        d          }t          j        d          }t          j        d          }t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w 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   rC   r0   r   formatr   r   r   
style_file	stylepaths        r   testSetCustomStyleBasedOnYapfz-CommandLineTest.testSetCustomStyleBasedOnYapf  s     (   'o /    "  J
 
	 0*	=	= ;


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;   -BBBc                 <   t          j        d          }t          j        d          }t          j        d          }t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w 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   s        r   %testSetCustomStyleSpacesBeforeCommentz5CommandLineTest.testSetCustomStyleSpacesBeforeComment  s     (   'o /    "  J 
	 0*	=	= ;


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nz        if True: pass
        r   r!   s      r   testReadSingleLineCodeFromStdinz/CommandLineTest.testReadSingleLineCodeFromStdin*  r   r   c                    t          j        d          }t          j        d| j                  5 \  }}t          j        | j        |d          5 }	 t          j        t          d|gz   |           n7# t          j	        $ r%}| 
                    |j        d           Y d }~nd }~ww xY wd d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nzp        '''The module docstring.'''
        # -*- coding: utf-8 -*-
        def f():
            x = 37
        r   )r   r   r   r   r   rV   )r   r   r   r   r0   rC   r   r   r   CalledProcessErrorre   
returncode)r   r   r   r   rG   es         r   testEncodingVerificationz(CommandLineTest.testEncodingVerification3  s    (   
	d.
0 
0 
0 ,3;C!

,U< < < ,?G	,

x.B B3
O
O
O
O
O, 	, 	, 	,


1<
+
+
+
+
+
+
+
+	,	, , , , , , , , , , , , , , ,, , , , , , , , , , , , , , , , , ,s_    CB6 A32B63B'B"B6"B''B6*C6B:	:C=B:	>CCCc                     t          j        d          }t          j        d          }|                     ||ddg           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!   s      r   testReformattingSpecificLinesz-CommandLineTest.testReformattingSpecificLinesE  si     	( 	 	 'o 
/ 
 
 	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           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!   s      r   4testOmitFormattingLinesBeforeDisabledFunctionCommentzDCommandLineTest.testOmitFormattingLinesBeforeDisabledFunctionCommentc  si     (   'o /   	 %(  * * * * *r   c                     t          j        d          }t          j        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!   s      r   testReformattingSkippingLinesz-CommandLineTest.testReformattingSkippingLinesw  sR     
( 
 
 'o /   	-/FGGGGGr   c                     t          j        d          }t          j        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!   s      r   #testReformattingSkippingToEndOfFilez3CommandLineTest.testReformattingSkippingToEndOfFile  sR     (  " 'o /  & 	-/FGGGGGr   c                     t          j        d          }t          j        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!   s      r   "testReformattingSkippingSingleLinez2CommandLineTest.testReformattingSkippingSingleLine  R     (   'o 
/ 
 
 	-/FGGGGGr   c                     t          j        d          }t          j        d          }|                     ||           d S )Nz`        A = set([
            'hello',
            'world',
        ])  # yapf: disable
        r   r!   s      r   testDisableWholeDataStructurez-CommandLineTest.testDisableWholeDataStructure  R     (   'o /   	-/FGGGGGr   c                     t          j        d          }t          j        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!   s      r    testDisableButAdjustIndentationsz0CommandLineTest.testDisableButAdjustIndentations  r   r   c                     t          j        d          }t          j        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!   s      r   !testRetainingHorizontalWhitespacez1CommandLineTest.testRetainingHorizontalWhitespace  r   r   c                 j   t          j        d          }t          j        d          }|                     ||ddg           t          j        d          }t          j        d          }|                     ||g d           t          j        d	          }|                     ||dd
g           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!   s      r   testRetainingVerticalWhitespacez/CommandLineTest.testRetainingVerticalWhitespace  s    (   'o /   	 %(  * * *
   (  " 'o /   	<<<  > > >
   (   	*9e:L  N N N N Nr   c                 B    d}d}|                      ||ddg           d S )Nz# \
# \
# \

x = {
}
r   1-1r   r   r!   s      r   5testVerticalSpacingWithCommentWithContinuationMarkerszECommandLineTest.testVerticalSpacingWithCommentWithContinuationMarkersU  sI     	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nz        a = line_to_format
        def f():
            x = y + 42; z = n * 42
            if True: a += 1 ; b += 1 ; c += 1
        z        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!   s      r   *testRetainingSemicolonsWhenSpecifyingLinesz:CommandLineTest.testRetainingSemicolonsWhenSpecifyingLinesk  si     (   'o /   	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           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>"""
        aj          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!   s      r   testDisabledMultilineStringsz,CommandLineTest.testDisabledMultilineStrings  si     	( 	 	 'o /   	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nz        # yapf: disable
        A = set([
            'hello',
            'world',
        ])
        # yapf: enable
        B = set([
            'hello',
            'world',
        ])  # yapf: disable
        r   z1-10r   r   r!   s      r   testDisableWhenSpecifyingLinesz.CommandLineTest.testDisableWhenSpecifyingLines  si     (   'o /   	 &)  + + + + +r   c                     t          j        d          }t          j        d          }|                     ||ddg           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!   s      r   "testDisableFormattingInDataLiteralz2CommandLineTest.testDisableFormattingInDataLiteral  si     (  & 'o /   	 '*  , , , , ,r   c                     t          j        d          }t          j        d          }|                     ||ddg           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!   s      r   :testRetainVerticalFormattingBetweenDisabledAndEnabledLineszJCommandLineTest.testRetainVerticalFormattingBetweenDisabledAndEnabledLines  i     
( 
 
 'o /   	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nz        class A(object):
            def aaaaaaaaaaaaa(self):
                pass


            def bbbbbbbbbbbbb(self):  # 5
                pass
        z        class A(object):
            def aaaaaaaaaaaaa(self):
                pass

            def bbbbbbbbbbbbb(self):  # 5
                pass
        r   z4-4r   r   r!   s      r   0testRetainVerticalFormattingBetweenDisabledLinesz@CommandLineTest.testRetainVerticalFormattingBetweenDisabledLines  si     (   'o /   	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nr  r  r   z5-6r   r   r!   s      r   ,testFormatLinesSpecifiedInMiddleOfExpressionz<CommandLineTest.testFormatLinesSpecifiedInMiddleOfExpression  r  r   c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nz        def foo():
            '''First line.
            Second line.
            '''  # comment
            x = '''hello world'''  # second comment
            return 42  # another comment
        r   r   r   r   r!   s      r   #testCommentFollowingMultilineStringz3CommandLineTest.testCommentFollowingMultilineString,  si     (   'o /   	 %(  * * * * *r   c                 
   t          j        d          }t          j        d          }|                     ||dg           t          j        d          }t          j        d          }|                     ||dg           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   expected_formatted_fb_codes       r   testDedentClosingBracketz(CommandLineTest.testDedentClosingBracketB  s     ( 	 	
 'o / 	 	
 	%&  ( ( (   ( 	 	 "* 2 "	 "	 	")*  , , , , ,r   c                    t          j        d          }t          j        d          }t          j        | j        d          5 \  }}|                    t          j        d                     |                                 |                     ||d                    |          g           d d d            d S # 1 swxY w 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   r0   writeflushr   r   )r   r   r   fnames        r   testCoalesceBracketsz$CommandLineTest.testCoalesceBracketsx  s"    (   'o /   
	T%5C	@	@	@ 6IQgg
/      ggiii


!&--d334  6 6 66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   A+B<<C C c                     t          j        d          }t          j        d          }|                     ||g d           d S )Nzq        def foo():
          def bar():
            return {msg_id: author for author, msg_id in reader}
        zr        def foo():

          def bar():
            return {msg_id: author for author, msg_id in reader}
        r   r   --styler	   r   r   r!   s      r   testPseudoParenSpacesz%CommandLineTest.testPseudoParenSpaces  sj     (  
 'o /   	;;;  = = = = =r   c                     t          j        d          }t          j        d          }|                     ||g 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!   s      r   &testMultilineCommentFormattingDisabledz6CommandLineTest.testMultilineCommentFormattingDisabled  sj     (   'o /   	;;;  = = = = =r   c                     t          j        d          }t          j        d          }|                     ||g d           d S )Nzh        import os

        SCOPES = [
            'hello world'  # This is a comment.
        ]
        r   r   r   r!   s      r   *testTrailingCommentsWithDisabledFormattingz:CommandLineTest.testTrailingCommentsWithDisabledFormatting  sj     (   'o /   	;;;  = = = = =r   c                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w 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   rC   r0   r   r   r   r   r   style_contentsr   s        r   testUseTabszCommandLineTest.testUseTabs  s    

N 
	 0.	A	A ;Y


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;   -AA"Ac                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )Nz&def f():
  return ['hello', 'world',]
z2def f():
	return [
	    'hello',
	    'world',
	]
r(  r   r   r)  r*  s        r   testUseTabsWithzCommandLineTest.testUseTabsWith  s    N 
	 0.	A	A ;Y


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r-  c                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )NAdef 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*  s        r   &testUseTabsContinuationAlignStyleFixedz6CommandLineTest.testUseTabsContinuationAlignStyleFixed	      N 
	 0.	A	A ;Y


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r-  c                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )Nr1  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*  s        r   ,testUseTabsContinuationAlignStyleVAlignRightz<CommandLineTest.testUseTabsContinuationAlignStyleVAlignRight%  r3  r-  c                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )Nr1  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*  s        r   (testUseSpacesContinuationAlignStyleFixedz8CommandLineTest.testUseSpacesContinuationAlignStyleFixedA      N 
	 0.	A	A ;Y


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r-  c                     d}d}d}t          j        | j        |          5 }|                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )Nr1  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*  s        r   .testUseSpacesContinuationAlignStyleVAlignRightz>CommandLineTest.testUseSpacesContinuationAlignStyleVAlignRight\  r8  r-  c                    t          j        d          }t          j        d          }t          j        | j                  5 \  }}t          j        t          dgz   |t
          j        t
          j                  }|	                                \  }}| 
                    |d           |                     ||d                    |          g           d d d            d S # 1 swxY w Y   d S )	Nz3        def foo_function():
          pass
        z5        def foo_function():
            pass
        )r   z--style-help)r   r   r   r   r   r   )r   r   r   r   r0   r   r   r   r   r   re   r   r   )r   r   r   	stylefiler   r   r   r   s           r   testStyleOutputRoundTripz(CommandLineTest.testStyleOutputRoundTripw  sD    (   'o /  
 
	T%5	6	6	6 ; ;F9;D


(
(	" " "a
 mmooma
z3'''


!&--i889  ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   BC""C&)C&c                     t          j        d          }t          j        d          }|                     ||ddg           d S )Nzq        A = 42


        # A comment
        def x():
            pass
        def _():
            pass
        r   r   r   r   r!   s      r   testSpacingBeforeCommentsz)CommandLineTest.testSpacingBeforeComments  si     	( 	 	 'o 	/ 	 	 	 %(  * * * * *r   c                     t          j        d          }t          j        d          }|                     ||g 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!   s      r    testSpacingBeforeCommentsInDictsz0CommandLineTest.testSpacingBeforeCommentsInDicts  sj     (   'o /   	;;;  = = = = =r   zRequires Python 3.6c                 B    d}d}|                      ||ddg           d S )Nza = 4-b/c@d**37
za = 4-b / c@d**37
r!  zL{based_on_style: pep8, no_spaces_around_selected_binary_operators: "@,**,-"}r   r   r!   s      r   !testNoSpacesAroundBinaryOperatorsz1CommandLineTest.testNoSpacesAroundBinaryOperators  sO     	D
      r   c                 B    d}d}|                      ||ddi           d S )Nu   print("中文")
PYTHONIOENCODINGcp936)r   r   r!   s      r   testCP936Encodingz!CommandLineTest.testCP936Encoding  sC    *1)  + + + + +r   c                 B    d}d}|                      ||g d           d S )Nz-# yapf: disable
a = [
    1,
    2,

    3
]
)r!  r	   r   z1-100r   r   r!   s      r   testDisableWithLineRangesz)CommandLineTest.testDisableWithLineRanges  sJ     	===  ? ? ? ? ?r   )NN):r%   r&   r'   __doc__classmethodr   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/  r2  r5  r7  r:  r=  r?  rA  unittest
skipUnlessr   PY36rC  rG  rI  r(   r   r   r   r     s       99) ) ;) # # ;# )-"	J J J J8	N 	N 	N@ @ @"	@ 	@ 	@	@ 	@ 	@	H 	H 	HH H H( ( (; ; ;(; ; ;&H H H, , ,$* * *<* * *(H H H6%H %H %HNH H H.H H HH H HH H H.NN NN NN`* * *,* * *(* * *8+ + +<&, &, &,P* * *4* * *.* * *4* * *,., ., .,l6 6 66= = =" =  =  =D= = =(; ; ;.; ; ;0; ; ;8; ; ;8; ; ;6; ; ;6; ; ;0* * *4"= "= "=H 8y~'<==  >=  8y~'<==+ + >=+? ? ? ? ?r   r   c                       e Zd ZdZd Zd ZdS )BadInputTestz,Test yapf's behaviour when passed bad input.c                 V    d}|                      t          t          j        |           d S )Nz  a = 1
)rk   SyntaxErrorr   r   r   r=   s     r   testBadSyntaxzBadInputTest.testBadSyntax  s(    Dk8#6=====r   c                 `    d}|                      t          j        t          j        |           d S )Nzx = """hello
)rk   r   
TokenErrorr   r   rS  s     r   testBadCodezBadInputTest.testBadCode  s+    Dh)8+>EEEEEr   N)r%   r&   r'   rJ  rT  rW  r(   r   r   rP  rP     s=        44> > >F F F F Fr   rP  c                   0    e Zd Zed             Zd Zd ZdS )DiffIndentTestc                  @    t          j                    } d| d<   d| d<   | S )NrY   INDENT_WIDTHCONTINUATION_INDENT_WIDTHr   CreatePEP8Stylemy_styles    r   	_OwnStylezDiffIndentTest._OwnStyle  s*    $&&H H^,-H()Or   c                     t          j        |t          j        |                                                     \  }}|                     ||           d S Nr   r   r   r   SetGlobalStylera  re   r   s        r   r   zDiffIndentTest._Check  X     +u';DNN<L<L'M'MO O ONA,n=====r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nz:        for i in range(5):
         print('bar')
         z>        for i in range(5):
           print('bar')
           r   r!   s      r   r   zDiffIndentTest.testSimple  sP     (   'o /   	KK "9:::::r   N)r%   r&   r'   staticmethodra  r   r   r(   r   r   rY  rY    sK          <> > >
	; 	; 	; 	; 	;r   rY  c                   l    e Zd Zed             Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd ZdS )'HorizontallyAlignedTrailingCommentsTestc                  :    t          j                    } g d| d<   | S )N)      #   SPACES_BEFORE_COMMENTr]  r_  s    r   ra  z1HorizontallyAlignedTrailingCommentsTest._OwnStyle(  s.    $&&H) ) )H$%
 Or   c                     t          j        |t          j        |                                                     \  }}|                     ||           d S rc  )r   r   r   re  ra  r   r   s        r   r   z.HorizontallyAlignedTrailingCommentsTest._Check2  sX     +u';DNN<L<L'M'MO O ONA0.AAAAAr   c                     t          j        d          }t          j        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!   s      r   r   z2HorizontallyAlignedTrailingCommentsTest.testSimple7  sP     (   'o /   	KK "9:::::r   c                     t          j        d          }t          j        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!   s      r   	testBlockz1HorizontallyAlignedTrailingCommentsTest.testBlockL  P     (   'o /   	KK "9:::::r   c                     t          j        d          }t          j        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!   s      r   testBlockWithLongLinez=HorizontallyAlignedTrailingCommentsTest.testBlockWithLongLine_  rt  r   c                     t          j        d          }t          j        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!   s      r   testBlockFuncSuffixz;HorizontallyAlignedTrailingCommentsTest.testBlockFuncSuffixr  sP     
( 
 
 'o /   	KK "9:::::r   c                     t          j        d          }t          j        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!   s      r   testBlockCommentSuffixz>HorizontallyAlignedTrailingCommentsTest.testBlockCommentSuffix  sP     	( 	 	 'o 	/ 	 	 	KK "9:::::r   c                     t          j        d          }t          j        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
        aN          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!   s      r   testBlockIndentedFuncSuffixzCHorizontallyAlignedTrailingCommentsTest.testBlockIndentedFuncSuffix  sP     (   'o /    	KK "9:::::r   c                     t          j        d          }t          j        d          }|                     ||           d S )Nab          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!   s      r   testBlockIndentedCommentSuffixzFHorizontallyAlignedTrailingCommentsTest.testBlockIndentedCommentSuffix  P     
( 
 
 'o 
/ 
 
 	KK "9:::::r   c                     t          j        d          }t          j        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
        ah          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!   s      r   testBlockMultiIndentedz>HorizontallyAlignedTrailingCommentsTest.testBlockMultiIndented  sP     (   'o /   	KK "9:::::r   c                     t          j        d          }t          j        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!   s      r   testArgsz0HorizontallyAlignedTrailingCommentsTest.testArgs  r  r   c                     t          j        d          }t          j        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!   s      r   testDisableBlockz8HorizontallyAlignedTrailingCommentsTest.testDisableBlock  sP     (   'o /   	KK "9:::::r   c                     t          j        d          }t          j        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!   s      r   testDisabledLinez8HorizontallyAlignedTrailingCommentsTest.testDisabledLine.  sP     (   'o /   	KK "9:::::r   N)r%   r&   r'   rh  ra  r   r   rs  rv  rx  rz  r|  r~  r  r  r  r  r(   r   r   rj  rj  &  s          <B B B
; ; ;*; ; ;&; ; ;&; ; ;4; ; ;.; ; ;B; ; ;2; ; ;:; ; ;2; ; ;6; ; ; ; ;r   rj  c                   0    e Zd Zed             Zd Zd ZdS )"_SpacesAroundDictListTupleTestImplc                  J    t          j                    } d| d<   d| d<   d| d<   | S )NTDISABLE_ENDING_COMMA_HEURISTICF SPLIT_ALL_COMMA_SEPARATED_VALUES%SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATEDr]  r_  s    r   ra  z,_SpacesAroundDictListTupleTestImpl._OwnStyle@  s6    $&&H15H-.38H/08=H45Or   c                     t          j        |t          j        |                                                     \  }}|                     ||           d S rc  rd  r   s        r   r   z)_SpacesAroundDictListTupleTestImpl._CheckH  rf  r   c                     d | _         d S r,   )maxDiffr1   s    r   r2   z(_SpacesAroundDictListTupleTestImpl.setUpM  s    DLLLr   N)r%   r&   r'   rh  ra  r   r2   r(   r   r   r  r  >  sK          <> > >
    r   r  c                   4     e Zd Ze fd            Zd Z xZS )SpacesAroundDictTestc                 `    t          t          |                                           }d|d<   |S )NTSPACES_AROUND_DICT_DELIMITERS)superr  ra  r   r   	__class__s     r   ra  zSpacesAroundDictTest._OwnStyleS  /    &,,6688E-1E
)*Lr   c                     t          j        d          }t          j        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)
      aQ        { 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!   s      r   testStandardz!SpacesAroundDictTest.testStandardZ  sP     (
  " 'o /
  $ 	KK "9:::::r   r%   r&   r'   rK  ra  r  __classcell__r  s   @r   r  r  Q  sQ            ;$; $; $; $; $; $; $;r   r  c                   4     e Zd Ze fd            Zd Z xZS )SpacesAroundListTestc                 `    t          t          |                                           }d|d<   |S )NTSPACES_AROUND_LIST_DELIMITERS)r  r  ra  r  s     r   ra  zSpacesAroundListTest._OwnStyle  r  r   c                     t          j        d          }t          j        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!   s      r   r  z!SpacesAroundListTest.testStandard  sP     (
  * 'o /
  , 	KK "9:::::r   r  r  s   @r   r  r    sQ            ;,; ,; ,; ,; ,; ,; ,;r   r  c                   4     e Zd Ze fd            Zd Z xZS )SpacesAroundTupleTestc                 `    t          t          |                                           }d|d<   |S )NTSPACES_AROUND_TUPLE_DELIMITERS)r  r  ra  r  s     r   ra  zSpacesAroundTupleTest._OwnStyle  s/    '--7799E.2E
*+Lr   c                     t          j        d          }t          j        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!   s      r   r  z"SpacesAroundTupleTest.testStandard  sP     (
  . 'o /
  0 	KK "9:::::r   r  r  s   @r   r  r    sQ            ;0; 0; 0; 0; 0; 0; 0;r   r  __main__)(rJ  r   rt   osr5   r   rg   r.   r   rL  lib2to3.pgen2r   yapf.yapflibr   r   r   	yapftestsr   r   pathr   abspath__file__ROOT_DIR
executabler   YAPFTestr   TestCaser*   r   rP  rY  rj  r  r  r  r  r%   mainr(   r   r   <module>r     s     				  				      



    " " " " " " " " " " " "       ! ! ! ! ! !       & & & & & &7??27??27??8+D+DEEFF ~tVZ9KL; ; ; ; ;%. ; ; ;:~1 ~1 ~1 ~1 ~1X& ~1 ~1 ~1B
u? u? u? u? u?h' u? u? u?p#	F 	F 	F 	F 	F8$ 	F 	F 	F; ; ; ; ;X& ; ; ;4U; U; U; U; U;.>.G U; U; U;p    ):   &-; -; -; -; -;= -; -; -;`5; 5; 5; 5; 5;= 5; 5; 5;p9; 9; 9; 9; 9;> 9; 9; 9;x z(-///// r   