
    ?d2                        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(                  j+                  ej(                  j-                  ej(                  j+                  e                  Zej2                  d
dddgZ G d dej6                        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j6                        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	jP                          yy)#zTests for yapf.yapf.    N)tokenize)errors)	py3compat)style)yapf_api)utils)yapf_test_helperz-myapfz--verifyz--no-local-stylec                   d    e Zd Zd Zd Zd Z ej                  ej                  d      d        Z
y)FormatCodeTestc                 \    t        j                  |d      \  }}| j                  ||       y )Nr
   style_config)r   
FormatCodeassertCodeEqualselfunformatted_codeexpected_formatted_codeformatted_code_s        5/usr/lib/python3/dist-packages/yapftests/yapf_test.py_CheckzFormatCodeTest._Check-   s-     ++v/NA0.A    c                 R    t        j                  d      }| j                  ||       y )Nz        print('foo')
        textwrapdedentr   )r   r   s     r   
testSimplezFormatCodeTest.testSimple2   s(     (  	KK "23r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nz        if True:
          pass(        if True:
          pass
        r   r   r   r   s      r   testNoEndingNewlinez"FormatCodeTest.testNoEndingNewline8   s>     (  'oo /  	KK "9:r   Requires Python 3.6c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nza.print
r   r"   s      r   testPrintAfterPeriodz#FormatCodeTest.testPrintAfterPeriodB   s0    7&ooo>KK "9:r   N)__name__
__module____qualname__r   r   r#   unittest
skipUnlessr   PY36r&    r   r   r   r   +   s:    B
4; 8y~~'<=; >;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 Zy)FormatFileTestc                 6    t        j                         | _        y Ntempfilemkdtemptest_tmpdirr   s    r   setUpzFormatFileTest.setUpK   s    '')Dr   c                 B    t        j                  | j                         y r1   shutilrmtreer5   r6   s    r   tearDownzFormatFileTest.tearDownN   s    
MM$""#r   c                     ||k7  rbd}|dz  }|dj                  |j                               z  }|dz  }|dj                  |j                               z  }| j                  |       y y )NzCode format mismatch:
zExpected:
 >z
 > z
Actual:
 >)join
splitlinesfail)r   expected_codecodemsgs       r   r   zFormatFileTest.assertCodeEqualQ   si    }%c	_c	W\\-22455c	_c	W\\$//+,,c
iin r   c                    t        j                  d      }t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)N'        if True:
         pass
        z*        if True:
            pass
        r!   pep8r   r
   r   r   r   TempFileContentsr5   r   
FormatFiler   )r   r   expected_formatted_code_pep8expected_formatted_code_yapffilepathr   r   s          r   testFormatFilezFormatFileTest.testFormatFile[   s     (  $,?? 4 $  $,?? 4 $  
		 0 02B	C Ix%00Ona
7H%00Ona
7HI I Is    ACCc                    t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nz[        if a:    b

        # yapf: disable
        if f:    g

        if h:    i
        zX        if a: b

        # yapf: disable
        if f:    g

        if h:    i
        rF   r   rG   r   r   r   rL   r   r   s         r   testDisableLinesPatternz&FormatFileTest.testDisableLinesPatterno   s     (  'oo /  
		 0 02B	C Dx%00Ona
2NCD D D   .BBc                    t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)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
        rF   r   rG   rO   s         r   "testDisableAndReenableLinesPatternz1FormatFileTest.testDisableAndReenableLinesPattern        (  'oo /  
		 0 02B	C Dx%00Ona
2NCD D DrQ   c                    t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)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
        rF   r   rG   rO   s         r   testFmtOnOffzFormatFileTest.testFmtOnOff   rT   rQ   c                 
   t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   uxY w# 1 sw Y   y xY w)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
        rF   r   z      def foo_function():
          # some comment
          # yapf: disable

          foo(
          bar,
          baz
          )

          # yapf: enable
      rG   )r   r   r   rL   r   r   rB   s          r   !testDisablePartOfMultilineCommentz0FormatFileTest.testDisablePartOfMultilineComment   s     
( 
 'oo 
/ 
 
		 0 02B	C Dx%00Ona
2NCD ?? 
 D 
		 0 0$	7 18%00Ona
401 1!D D 1 1s   .C-6.C9-C69Dc                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nav          # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        rF   r   rG   r   rB   rL   r   r   s        r   testEnabledDisabledSameCommentz-FormatFileTest.testEnabledDisabledSameComment   sm    ??  D 
		 0 0$	7 18%00Ona
401 1 1   .A--A6c                    t        j                  d      }t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |ddg      \  }}}| j                  ||       t        j                  |ddg      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)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
        rF   )      )r   lines)   ra   rG   )r   r   "expected_formatted_code_lines1and2expected_formatted_code_lines3rL   r   r   s          r   testFormatFileLinesSelectionz+FormatFileTest.testFormatFileLinesSelection   s     (  *2 : *& &.__ 6 &" 
		 0 02B	C Kx%00
x9na
=~N%00
x9na
9>JK K Ks    ACCc                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  d|       d d d        y # 1 sw Y   y xY w)NrE   T)
print_diffz+  pass)r   r   r   rH   r5   r   rI   assertIn)r   r   rL   diffr   s        r   testFormatFileDiffz!FormatFileTest.testFormatFileDiff	  sl     (  
		 0 02B	C &x&&xDAjdAq
mmJ%& & &r\   c                 ,   d}d}t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  |d        t        |      5 }t        j                  d   dk  r0| j                  ||j                         j                  d             n | j                  ||j                                d d d        | j                  t        t        j                  |dd       d d d        y # 1 sw Y   :xY w# 1 sw Y   y xY w)	NzTrue==False
zTrue == False
T)in_placer   r_   ascii)rk   rf   )r   rH   r5   r   rI   assertEqualopensysversion_infor   readdecodeassertRaises
ValueError)r   r   r   rL   resultr   fds          r   testFormatFileInPlacez$FormatFileTest.testFormatFileInPlace  s    ''N			 0 02B	C x((DAlfa
vt$> :RA!#


~rwwy/?/?/H
I


~rwwy
9	: 




   : : s$   9D
A'C>0D
>D	D

Dc                 D   t        j                         }t        j                  |      }t        j                  d      }|j                  |       | j                  t        t        j                  d|j                         | j                  |j                         d       y )Nmyloggerznot_a_file.py)loggerz5[Errno 2] No such file or directory: 'not_a_file.py'
)r   StringIOloggingStreamHandler	getLogger
addHandlerrs   IOErrorr   rI   errorrm   getvalue)r   streamhandlerrz   s       r   
testNoFilezFormatFileTest.testNoFile%  s    !F##F+Gz*F
g$$ofll  LV__&MOr   c                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nz        foo = [# A list of things
               # bork
            'one',
            # quark
            'two'] # yapf: disable
        rF   r   rG   rZ   s        r   testCommentsUnformattedz&FormatFileTest.testCommentsUnformatted/  sm    ??  D 
		 0 0$	7 18%00Ona
401 1 1r\   c                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)NzP        # yapf: disable
        a = [
        1]
        # yapf: enable
        rF   r   rG   rZ   s        r   )testDisabledHorizontalFormattingOnNewLinez8FormatFileTest.testDisabledHorizontalFormattingOnNewLine;  sm    ??  D 
		 0 0$	7 18%00Ona
401 1 1r\   c                    t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)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
        rF   r   rG   rO   s         r    testSplittingSemicolonStatementsz/FormatFileTest.testSplittingSemicolonStatementsF  s     ( 
 'oo /  
		 0 02B	C Dx%00Ona
2NCD D DrQ   c                    t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)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
        rF   r   rG   rO   s         r   testSemicolonStatementsDisabledz.FormatFileTest.testSemicolonStatementsDisabledY  s     ( 
 'oo /  
		 0 02B	C Dx%00Ona
2NCD D DrQ   c                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nz7        # yapf: disable
        if True: a ; b
        rF   r   rG   rZ   s        r   (testDisabledSemiColonSeparatedStatementsz7FormatFileTest.testDisabledSemiColonSeparatedStatementsk  sm    ??  D 
		 0 0$	7 18%00Ona
401 1 1r\   c                     t        j                  d      }t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nz        # yapf: disable

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

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r
   r   rG   rZ   s        r   testDisabledWithPrecedingTextz,FormatFileTest.testDisabledWithPrecedingText  r   r\   c                     d}t        j                  | j                  |      5 }t        j                  |d      \  }}}| j                  ||       d d d        y # 1 sw Y   y xY w)Nzclass _():
  pass
r
   r   )r   rH   r5   r   rI   r   rZ   s        r   testCRLFLineEndingz!FormatFileTest.testCRLFLineEnding  s]    &D			 0 0$	7 18%00Ona
401 1 1s   .AA#N)r'   r(   r)   r7   r<   r   rM   rP   rS   rV   rX   r[   rd   ri   rw   r   r   r   r   r   r   r   r   r   r-   r   r   r/   r/   I   st    *$I(D*D.D.*1X1K<&&O
1	1D&D$11&1&1r   r/   c                   "   e Zd ZdZed        Zed        Z	 	 d8dZ ej                  e
j                  d      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, Z1d- Z2d. Z3d/ Z4d0 Z5d1 Z6d2 Z7d3 Z8d4 Z9 ej                  e
j                  d      d5        Z: ej                  e
j                  d      d6        Z;d7 Z<y)9CommandLineTestz1Test how calling yapf from the command line acts.c                 6    t        j                         | _        y r1   r2   clss    r   
setUpClasszCommandLineTest.setUpClass  s    &&(COr   c                 B    t        j                  | j                         y r1   r9   r   s    r   tearDownClasszCommandLineTest.tearDownClass  s    
MM#//"r   Nc                 R   t         |xs g z   }t        j                  |t        j                  t        j                  t        j                  |      }|j	                  |j                  d            \  }}| j                  |d       | j                  |j                  d      |       y)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encoderm   assertMultiLineEqualrr   )	r   unformattedexpectedextra_optionsr   cmdlinepreformatted_code
stderrdatas	            r   assertYapfReformatsz#CommandLineTest.assertYapfReformats  s      ]0b1Goo	A $%==;'$) jZ%.55g>Ir   r$   c                 N   t        j                  d      }t        j                  | j                  d      5 \  }}t        j
                  | j                  |d      5 }t        j                  t        d|gz   |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nu4           def foo():
            print('⇒')
        .py)dirnamesuffixr   --diffr   )	r   r   r   NamedTempFiler5   rH   r   
check_callr   )r   r   outr   rL   s        r   testUnicodeEncodingPipedToFilez.CommandLineTest.testUnicodeEncodingPipedToFile  s     (  
		  
0 N3;C!!


,U< N?GkXx,@@MNN NN NN Ns#   &B!B>BB	BB$c                    t        j                  d      }t        j                  d      }t        j                  | j                  |d      5 }t        j                  t        d|gz         }|j                          t        j                  |dd      5 }|j                         }d d d        d d d        | j                  |       y # 1 sw Y   $xY w# 1 sw Y   (xY w)	N,        def foo():
          x = 37
        .        def foo():
            x = 37
        r   r   
--in-placer modenewliner   r   r   rH   r5   r   r   r   waitiorn   rq   rm   r   r   r   rL   r   rv   r   s          r   testInPlaceReformattingz'CommandLineTest.testInPlaceReformatting  s     (  'oo /  
		*5
: %=E


;,)AA
Baffh778#r2 %b779%	% 	%'>?% %	% %%   ACC%CC	CCc                 v   d}d}t        j                  | j                  |d      5 }t        j                  t
        d|gz         }|j                          t        j                  |ddd	      5 }|j                         }d d d        d d d        | j                  |       y # 1 sw Y   $xY w# 1 sw Y   (xY w)
Nz


r   r   r   r   r   r   r   encodingr   r   rH   r5   r   r   r   r   r   rn   rq   rm   r   s          r   testInPlaceReformattingBlankz,CommandLineTest.testInPlaceReformattingBlank  s    #			*5
: %=E


;,)AA
Baffh778#D %779%	% 	%'>?% %	% %$   AB//B# B/#B,	(B//B8c                 v   d}d}t        j                  | j                  |d      5 }t        j                  t
        d|gz         }|j                          t        j                  |ddd	      5 }|j                         }d d d        d d d        | j                  |       y # 1 sw Y   $xY w# 1 sw Y   (xY w)
Nz

z
r   r   r   r   r   r   r   r   r   s          r   %testInPlaceReformattingWindowsNewLinez5CommandLineTest.testInPlaceReformattingWindowsNewLine  s    "%			*5
: %=E


;,)AA
Baffh778#D %779%	% 	%'>?% %	% %r   c                    t        j                  d      }t        j                  d      }t        j                  | j                  |d      5 }t        j                  t        d|gz         }|j                          t        j                  |dd      5 }|j                         }d d d        d d d        | j                  |       y # 1 sw Y   $xY w# 1 sw Y   (xY w)	Nzdef foo(): x = 37r   r   r   r   r   r   r   r   r   s          r    testInPlaceReformattingNoNewLinez0CommandLineTest.testInPlaceReformattingNoNewLine  s    ';<&oo /  
		*5
: %=E


;,)AA
Baffh778#r2 %b779%	% 	%'>?% %	% %r   c                 v   d}d}t        j                  | j                  |d      5 }t        j                  t
        d|gz         }|j                          t        j                  |ddd      5 }|j                         }d d d        d d d        | j                  |       y # 1 sw Y   $xY w# 1 sw Y   (xY w)Nr   r   r   r   r   r   r   r   r   s          r   testInPlaceReformattingEmptyz,CommandLineTest.testInPlaceReformattingEmpty	  s    !			*5
: %=E


;,)AA
Baffh778#D %779%	% 	%'>?% %	% %r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nr   r   r   r   r   r"   s      r   testReadFromStdinz!CommandLineTest.testReadFromStdin  s@     (  'oo /  	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nz!        s =   "foo\nbar"
        z        s = "foo\nbar"
        r   r"   s      r   #testReadFromStdinWithEscapedStringsz3CommandLineTest.testReadFromStdinWithEscapedStrings  @     (  'oo /  	-/FGr   c                     t        j                  d      }t        j                  d      }| j                  ||dg       y )N6        def foo(): # trail
            x = 37
        z5        def foo():  # trail
          x = 37
        z--style=yapfr   r   r"   s      r   testSetYapfStylez CommandLineTest.testSetYapfStyle(  sM     (  'oo /  	%&  (r   c                 4   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }| j                  ||dj                  |      g       d d d        y # 1 sw Y   y xY w)Nr   z7        def foo():    # trail
          x = 37
        zX        [style]
        based_on_style = yapf
        spaces_before_comment = 4
        --style={0}r   r   r   r   rH   r5   r   formatr   r   r   
style_file	stylepaths        r   testSetCustomStyleBasedOnYapfz-CommandLineTest.testSetCustomStyleBasedOnYapf6  s     (  'oo /   " J
 
		 0 0*	= ;


!&--i89  ;; ; ;    %BBc                 4   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  | j                  |      5 }| j                  ||dj                  |      g       d d d        y # 1 sw Y   y xY w)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.testSetCustomStyleSpacesBeforeCommentJ  s     (  'oo /   " J 
		 0 0*	= ;


!&--i89  ;; ; ;r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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   |       d d d        d d d        y # t        j                  $ r&}| j                  |j                  d       Y d }~Ed }~ww xY w# 1 sw Y   NxY w# 1 sw Y   y xY w)Nzp        '''The module docstring.'''
        # -*- coding: utf-8 -*-
        def f():
            x = 37
        r   )r   r   r   r   r   r^   )r   r   r   r   r5   rH   r   r   r   CalledProcessErrorrm   
returncode)r   r   r   r   rL   es         r   testEncodingVerificationz(CommandLineTest.testEncodingVerificationf  s     (  
		d..
0 ,3;C!!


,U< ,?G	,


x.B B3
O,, , ,, 	,


1<<
+
+	,	, ,, ,sG   &CC B?CC	#C?CC		CC	CC!c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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.testReformattingSpecificLinesx  sO     	( 	 'oo 
/ 
 	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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.testOmitFormattingLinesBeforeDisabledFunctionComment  sO     (  'oo /  	 %(  *r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testReformattingSkippingLines  s@     
( 
 'oo /  	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  s@     ( " 'oo / & 	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  @     (  'oo 
/ 
 	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nz`        A = set([
            'hello',
            'world',
        ])  # yapf: disable
        r   r"   s      r   testDisableWholeDataStructurez-CommandLineTest.testDisableWholeDataStructure  s@     (  'oo /  	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  s@     (  'oo /  	-/FGr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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                 Z   t        j                  d      }t        j                  d      }| j                  ||ddg       t        j                  d      }t        j                  d      }| j                  ||g d       t        j                  d	      }| j                  ||dd
g       y )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     (  'oo /  	 %(  *
   ( " 'oo /  	<  >
   (  	*9e:L  Nr   c                 8    d}d}| j                  ||ddg       y )Nz# \
# \
# \

x = {
}
r   1-1r   r   r"   s      r   5testVerticalSpacingWithCommentWithContinuationMarkerszECommandLineTest.testVerticalSpacingWithCommentWithContinuationMarkers  s5     	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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"   s      r   *testRetainingSemicolonsWhenSpecifyingLinesz:CommandLineTest.testRetainingSemicolonsWhenSpecifyingLines  sO     (  'oo /  	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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"   s      r   testDisabledMultilineStringsz,CommandLineTest.testDisabledMultilineStrings  O     	( 	 'oo 	/ 	 	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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  sO     (  'oo /  	 &)  +r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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  sO     ( & 'oo /  	 '*  ,r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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  O     
( 
 'oo /  	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )Nz        class A(object):
            def aaaaaaaaaaaaa(self):
                pass


            def bbbbbbbbbbbbb(self):  # 5
                pass
        r   z4-4r   r   r"   s      r   0testRetainVerticalFormattingBetweenDisabledLinesz@CommandLineTest.testRetainVerticalFormattingBetweenDisabledLines,  O     (  'oo /  	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )Nr  r  r   z5-6r   r   r"   s      r   ,testFormatLinesSpecifiedInMiddleOfExpressionz<CommandLineTest.testFormatLinesSpecifiedInMiddleOfExpressionD  r  r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )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^  sO     (  'oo /  	 %(  *r   c                     t        j                  d      }t        j                  d      }| j                  ||dg       t        j                  d      }t        j                  d      }| j                  ||dg       y )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.testDedentClosingBrackett  s     ( 	
 'oo / 	
 	%&  (   ( 	 "* 2 "	 	")*  ,r   c                 z   t        j                  d      }t        j                  d      }t        j                  | j                  d      5 \  }}|j                  t        j                  d             |j                          | j                  ||dj                  |      g       d d d        y # 1 sw Y   y xY w)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   r5   writeflushr   r   )r   r   r   fnames        r   testCoalesceBracketsz$CommandLineTest.testCoalesceBrackets  s     (  'oo /  
		T%5%5C	@ 6IQgg
//   ggi


!&--d34  66 6 6s   AB11B:c                     t        j                  d      }t        j                  d      }| j                  ||g d       y )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"   s      r   testPseudoParenSpacesz%CommandLineTest.testPseudoParenSpaces  sJ     ( 
 'oo / 
 	;  =r   c                     t        j                  d      }t        j                  d      }| j                  ||g d       y )Na          # This is a comment
        FOO = {
            aaaaaaaa.ZZZ: [
                bbbbbbbbbb.Pop(),
                # Multiline comment.
                # Line two.
                bbbbbbbbbb.Pop(),
            ],
            'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
                ('yyyyy', zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz),
            '#': lambda x: x  # do nothing
        }
        r0  r   r   r"   s      r   &testMultilineCommentFormattingDisabledz6CommandLineTest.testMultilineCommentFormattingDisabled  sJ     (  'oo /  	;  =r   c                     t        j                  d      }t        j                  d      }| j                  ||g d       y )Nzh        import os

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


        # A comment
        def x():
            pass
        def _():
            pass
        r   r   r   r   r"   s      r   testSpacingBeforeCommentsz)CommandLineTest.testSpacingBeforeComments  r  r   c                     t        j                  d      }t        j                  d      }| j                  ||g d       y )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'
        }
        )r1  r
   r   r  r   r   r"   s      r    testSpacingBeforeCommentsInDictsz0CommandLineTest.testSpacingBeforeCommentsInDicts  sJ     (  'oo /  	;  =r   c                     t        j                  d      }t        j                  d      }| j                  ||ddg       y )Nz        # yapf_lines_bug.py
        # yapf: disable
        def outer_func():
            def inner_func():
                return
            return
        # yapf: enable
        r   z1-8r   r   r"   s      r   testDisableWithLinesOptionz*CommandLineTest.testDisableWithLinesOption  r   r   c                 8    d}d}| j                  ||ddg       y )Nza = 4-b/c@d**37
za = 4-b / c@d**37
r1  zL{based_on_style: pep8, no_spaces_around_selected_binary_operators: "@,**,-"}r   r  r"   s      r   !testNoSpacesAroundBinaryOperatorsz1CommandLineTest.testNoSpacesAroundBinaryOperators  s;     	D
  r   c                 8    d}d}| j                  ||ddi       y )Nu   print("中文")
PYTHONIOENCODINGcp936)r   r  r"   s      r   testCP936Encodingz!CommandLineTest.testCP936Encoding'  s/    *1)  +r   c                 8    d}d}| j                  ||g d       y )Nz-# yapf: disable
a = [
    1,
    2,

    3
]
)r1  r
   r   z1-100r   r  r"   s      r   testDisableWithLineRangesz)CommandLineTest.testDisableWithLineRanges0  s0     	=  ?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'  r.  r2  r4  r6  r<  r?  rB  rE  rG  rJ  rM  rO  rQ  rS  rU  rY  r[  r-   r   r   r   r     s   9) ) # # )-"	J8 8y~~'<=	N >	N@"	@	@@	@	HH(;(;&H,$*<*(H6%HNH.HH"H.NN`*,*$*4+<&,P*4*0*4*,.,l66=  =D=(;.;0;8;8;6;6;0*4"=H*0 8y~~'<= >  8y~~'<=+ >+?r   r   c                       e Zd ZdZd Zd Zy)BadInputTestz,Test yapf's behaviour when passed bad input.c                 f    d}| j                  t        j                  t        j                  |       y )Nz  a = 1
rs   r   	YapfErrorr   r   r   rB   s     r   testBadSyntaxzBadInputTest.testBadSyntaxL  s%    Df&&(;(;TBr   c                 f    d}| j                  t        j                  t        j                  |       y )Nzx = """hello
ra  rc  s     r   testBadCodezBadInputTest.testBadCodeP  s%    Df&&(;(;TBr   N)r'   r(   r)   r\  rd  rf  r-   r   r   r_  r_  I  s    4CCr   r_  c                   (    e Zd Zed        Zd Zd Zy)DiffIndentTestc                  B    t        j                         } d| d<   d| d<   | S )Nra   INDENT_WIDTHCONTINUATION_INDENT_WIDTHr   CreatePEP8Stylemy_styles    r   	_OwnStylezDiffIndentTest._OwnStyleW  s*    $$&H H^,-H()Or   c                     t        j                  |t        j                  | j	                                     \  }}| j                  ||       y Nr   r   r   r   SetGlobalStylerp  rm   r   s        r   r   zDiffIndentTest._Check^  @     ++u';';DNN<L'MONA,n=r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )Nz:        for i in range(5):
         print('bar')
         z>        for i in range(5):
           print('bar')
           r   r"   s      r   r   zDiffIndentTest.testSimplec  s>     (  'oo /  	KK "9:r   N)r'   r(   r)   staticmethodrp  r   r   r-   r   r   rh  rh  U  s     >
	;r   rh  c                   d    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y)'HorizontallyAlignedTrailingCommentsTestc                  <    t        j                         } g d| d<   | S )N)      #   SPACES_BEFORE_COMMENTrl  rn  s    r   rp  z1HorizontallyAlignedTrailingCommentsTest._OwnStyleq  s$    $$&H)H$%
 Or   c                     t        j                  |t        j                  | j	                                     \  }}| j                  ||       y rr  )r   r   r   rt  rp  r   r   s        r   r   z.HorizontallyAlignedTrailingCommentsTest._Check{  s@     ++u';';DNN<L'MONA0.Ar   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testSimple  s>     (  'oo /  	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testBlock  >     (  'oo /  	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  r  r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testBlockFuncSuffix  s>     
( 
 'oo /  	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  s>     	( 	 'oo 	/ 	 	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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"   s      r   testBlockIndentedFuncSuffixzCHorizontallyAlignedTrailingCommentsTest.testBlockIndentedFuncSuffix  s>     (  'oo /   	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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"   s      r   testBlockIndentedCommentSuffixzFHorizontallyAlignedTrailingCommentsTest.testBlockIndentedCommentSuffix  >     
( 
 'oo 
/ 
 	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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"   s      r   testBlockMultiIndentedz>HorizontallyAlignedTrailingCommentsTest.testBlockMultiIndented&  s>     (  'oo /  	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testArgsC  r  r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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\  s>     (  'oo /  	KK "9:r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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.testDisabledLinew  s>     (  'oo /  	KK "9:r   N)r'   r(   r)   rw  rp  r   r   r  r  r  r  r  r  r  r  r  r  r-   r   r   ry  ry  o  sR     B
;*;&;&;4;.;B;2;:;2;6;r   ry  c                   (    e Zd Zed        Zd Zd Zy)"_SpacesAroundDictListTupleTestImplc                  L    t        j                         } d| d<   d| d<   d| d<   | S )NTDISABLE_ENDING_COMMA_HEURISTICF SPLIT_ALL_COMMA_SEPARATED_VALUES%SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATEDrl  rn  s    r   rp  z,_SpacesAroundDictListTupleTestImpl._OwnStyle  s6    $$&H15H-.38H/08=H45Or   c                     t        j                  |t        j                  | j	                                     \  }}| j                  ||       y rr  rs  r   s        r   r   z)_SpacesAroundDictListTupleTestImpl._Check  ru  r   c                     d | _         y r1   )maxDiffr6   s    r   r7   z(_SpacesAroundDictListTupleTestImpl.setUp  s	    DLr   N)r'   r(   r)   rw  rp  r   r7   r-   r   r   r  r    s     >
r   r  c                   .     e Zd Ze fd       Zd Z xZS )SpacesAroundDictTestc                 6    t         t        |          }d|d<   |S )NTSPACES_AROUND_DICT_DELIMITERS)superr  rp  r   r   	__class__s     r   rp  zSpacesAroundDictTest._OwnStyle  #    &68E-1E
)*Lr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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"   s      r   testStandardz!SpacesAroundDictTest.testStandard  s>     (
 " 'oo /
 $ 	KK "9:r   r'   r(   r)   r]  rp  r  __classcell__r  s   @r   r  r    s     $;r   r  c                   .     e Zd Ze fd       Zd Z xZS )SpacesAroundListTestc                 6    t         t        |          }d|d<   |S )NTSPACES_AROUND_LIST_DELIMITERS)r  r  rp  r  s     r   rp  zSpacesAroundListTest._OwnStyle  r  r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  s>     (
 * 'oo /
 , 	KK "9:r   r  r  s   @r   r  r    s     ,;r   r  c                   .     e Zd Ze fd       Zd Z xZS )SpacesAroundTupleTestc                 6    t         t        |          }d|d<   |S )NTSPACES_AROUND_TUPLE_DELIMITERS)r  r  rp  r  s     r   rp  zSpacesAroundTupleTest._OwnStyle  s#    '79E.2E
*+Lr   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y )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  s>     (
 . 'oo /
 0 	KK "9:r   r  r  s   @r   r  r    s     0;r   r  __main__))r\  r   r|   osr:   r   ro   r3   r   r*   lib2to3.pgen2r   yapf.yapflibr   r   r   r   	yapftestsr   r	   pathr   abspath__file__ROOT_DIR
executabler   YAPFTestr   TestCaser/   r   r_  rh  ry  r  r  r  r  r'   mainr-   r   r   <module>r     sL    	  	   
    "  "  !  &77??277??277??8+DEF ~~tVZ9KL;%.. ;<U1X&& U1p
e?h'' e?P%	C8$$ 	C;X&& ;4U;.>.G.G U;p):): &-;= -;`5;= 5;p9;> 9;x z(--/ r   