o
    ?n0j                     @   s  d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddlm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ ejejejeZejd
dddgZG dd dejZG dd de	jZG dd de	jZG dd de	jZ G dd de	jZ!G dd dejZ"G dd de	jZ#G dd de#Z$G dd de#Z%G d d! d!e#Z&e'd"kre	(  dS dS )#zTests for yapf.yapf.    N)StringIO)tokenize)errors)style)yapf_api)utils)yapf_test_helperz-myapfz--verifyz--no-local-stylec                   @   s$   e Zd Zdd Zdd Zdd ZdS )FormatCodeTestc                 C   s"   t j|dd\}}| || d S )Nr	   style_config)r   
FormatCodeassertCodeEqualselfunformatted_codeexpected_formatted_codeformatted_code_ r   Z/home/wildlama/miniconda3/envs/lam_a2e/lib/python3.10/site-packages/yapftests/yapf_test.py_Check-   s   
zFormatCodeTest._Checkc                 C   s   t d}| || d S )Nz        print('foo')
        textwrapdedentr   )r   r   r   r   r   
testSimple2   s   
zFormatCodeTest.testSimplec                 C   $   t d}t d}| || d S )Nz        if True:
          pass(        if True:
          pass
        r   r   r   r   r   r   r   testNoEndingNewline8   s   

z"FormatCodeTest.testNoEndingNewlineN)__name__
__module____qualname__r   r   r   r   r   r   r   r
   +   s    r
   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+S ),FormatFileTestc                 C      t  | _d S Ntempfilemkdtemptest_tmpdirr   r   r   r   setUpE   s   zFormatFileTest.setUpc                 C      t | j d S r%   shutilrmtreer)   r*   r   r   r   tearDownH   s   zFormatFileTest.tearDownc                 C   sR   ||kr'd}|d7 }|d | 7 }|d7 }|d | 7 }| | d S d S )NzCode format mismatch:
zExpected:
 >z
 > z
Actual:
 >)join
splitlinesZfail)r   Zexpected_codecodemsgr   r   r   r   K   s   zFormatFileTest.assertCodeEqualc                 C   s   t d}t d}t d}t| j|)}tj|dd\}}}| || tj|dd\}}}| || W d    d S 1 sBw   Y  d S )N'        if True:
         pass
        z*        if True:
            pass
        r   pep8r   r	   r   r   r   TempFileContentsr)   r   
FormatFiler   )r   r   Zexpected_formatted_code_pep8Zexpected_formatted_code_yapffilepathr   r   r   r   r   testFormatFileU   s   


"zFormatFileTest.testFormatFilec                 C   h   t d}t d}t| j|}tj|dd\}}}| || W d    d S 1 s-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
        r6   r   r7   r   r   r   r:   r   r   r   r   r   testDisableLinesPatterni   s   

"z&FormatFileTest.testDisableLinesPatternc                 C   r<   )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
        r6   r   r7   r=   r   r   r   "testDisableAndReenableLinesPattern~      

		"z1FormatFileTest.testDisableAndReenableLinesPatternc                 C   r<   )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
        r6   r   r7   r=   r   r   r   testFmtOnOff   r@   zFormatFileTest.testFmtOnOffc                 C   s   t d}t d}t| j|}tj|dd\}}}| || W d    n1 s,w   Y  t d}t| j|}tj|dd\}}}| || W d    d S 1 sYw   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
        r6   r   z      def foo_function():
          # some comment
          # yapf: disable

          foo(
          bar,
          baz
          )

          # yapf: enable
      r7   )r   r   r   r:   r   r   r3   r   r   r   !testDisablePartOfMultilineComment   s   


"z0FormatFileTest.testDisablePartOfMultilineCommentc                 C   ^   t d}t| j|}tj|dd\}}}| || W d    d S 1 s(w   Y  d S )Nav          # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        # yapf: disable
        a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee)
        # yapf: enable
        r6   r   r7   r   r3   r:   r   r   r   r   r   testEnabledDisabledSameComment   s
   
"z-FormatFileTest.testEnabledDisabledSameCommentc                 C   s   t d}t d}t d}t| j|-}tj|ddgd\}}}| || tj|ddgd\}}}| || W d    d S 1 sFw   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
        r6   )      )r   lines)   rI   r7   )r   r   Z"expected_formatted_code_lines1and2Zexpected_formatted_code_lines3r:   r   r   r   r   r   testFormatFileLinesSelection   s   


"z+FormatFileTest.testFormatFileLinesSelectionc                 C   s^   t d}t| j|}tj|dd\}}}| d| W d    d S 1 s(w   Y  d S )Nr5   T)
print_diffz+  pass)r   r   r   r8   r)   r   r9   assertIn)r   r   r:   diffr   r   r   r   testFormatFileDiff  
   
"z!FormatFileTest.testFormatFileDiffc              	   C   s   d}d}t | j|@}tj|dd\}}}| |d  t|}| ||  W d    n1 s3w   Y  | j	t
tj|ddd W d    d S 1 sNw   Y  d S )NzTrue==False
zTrue == False
T)in_place)rP   rK   )r   r8   r)   r   r9   assertEqualopenr   readassertRaises
ValueError)r   r   r   r:   resultr   fdr   r   r   testFormatFileInPlace  s    
"z$FormatFileTest.testFormatFileInPlacec                 C   sJ   |  t}td W d    n1 sw   Y  | t|jd d S )Nznot_a_file.pyz4[Errno 2] No such file or directory: 'not_a_file.py')rT   IOErrorr   r9   rQ   str	exception)r   contextr   r   r   
testNoFile  s   zFormatFileTest.testNoFilec                 C   rC   )Nz        foo = [# A list of things
               # bork
            'one',
            # quark
            'two'] # yapf: disable
        r6   r   r7   rD   r   r   r   testCommentsUnformatted$  s
   
"z&FormatFileTest.testCommentsUnformattedc                 C   rC   )NzP        # yapf: disable
        a = [
        1]
        # yapf: enable
        r6   r   r7   rD   r   r   r   )testDisabledHorizontalFormattingOnNewLine0  s
   
"z8FormatFileTest.testDisabledHorizontalFormattingOnNewLinec                 C   r<   )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
        r6   r   r7   r=   r   r   r    testSplittingSemicolonStatements;  s   

	"z/FormatFileTest.testSplittingSemicolonStatementsc                 C   r<   )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
        r6   r   r7   r=   r   r   r   testSemicolonStatementsDisabledN  s   

"z.FormatFileTest.testSemicolonStatementsDisabledc                 C   rC   )Nz7        # yapf: disable
        if True: a ; b
        r6   r   r7   rD   r   r   r   (testDisabledSemiColonSeparatedStatements`  rO   z7FormatFileTest.testDisabledSemiColonSeparatedStatementsc                 C   rC   )Nz        # yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   r7   rD   r   r   r   'testDisabledMultilineStringInDictionaryi  
   
"z6FormatFileTest.testDisabledMultilineStringInDictionaryc                 C   rC   )Na          # TODO(fix formatting): yapf: disable

        A = [
            {
                "aaaaaaaaaaaaaaaaaaa": '''
        bbbbbbbbbbb: "ccccccccccc"
        dddddddddddddd: 1
        eeeeeeee: 0
        ffffffffff: "ggggggg"
        ''',
            },
        ]
        r	   r   r7   rD   r   r   r   testDisabledWithPrecedingText|  rd   z,FormatFileTest.testDisabledWithPrecedingTextc                 C   sX   d}t | j|}tj|dd\}}}| || W d    d S 1 s%w   Y  d S )Nzclass _():
  pass
r	   r   )r   r8   r)   r   r9   r   rD   r   r   r   testCRLFLineEnding  s
   "z!FormatFileTest.testCRLFLineEndingN)r    r!   r"   r+   r0   r   r;   r>   r?   rA   rB   rE   rJ   rN   rX   r]   r^   r_   r`   ra   rb   rc   re   rf   r   r   r   r   r#   C   s,    
,		r#   c                   @   s  e Zd ZdZedd Zedd Z		dgddZd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Z d;d< Z!d=d> Z"d?d@ Z#dAdB Z$dCdD Z%dEdF Z&dGdH Z'dIdJ Z(dKdL Z)dMdN Z*dOdP Z+dQdR Z,dSdT Z-dUdV Z.dWdX Z/dYdZ Z0d[d\ Z1d]d^ Z2d_d` Z3dadb Z4dcdd Z5dedf Z6dS )hCommandLineTestz1Test how calling yapf from the command line acts.c                 C   r$   r%   r&   clsr   r   r   
setUpClass  s   zCommandLineTest.setUpClassc                 C   r,   r%   r-   rh   r   r   r   tearDownClass  s   zCommandLineTest.tearDownClassNc           	      C   s\   t |pg  }tj|tjtjtj|d}||d\}}| |d | |d| dS )a  Check that yapf reformats the given code as expected.

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

    Arguments:
      unformatted: unformatted code - input to yapf
      expected: expected formatted code at the output of yapf
      extra_options: iterable of extra command-line options to pass to yapf
      env: dict of environment variables.
    )stdoutstdinstderrenvz	utf-8-sig    utf-8N)	YAPF_BINARY
subprocessPopenPIPEcommunicateencoderQ   ZassertMultiLineEqualdecode)	r   Zunformattedexpectedextra_optionsro   Zcmdlinepreformatted_code
stderrdatar   r   r   assertYapfReformats  s   z#CommandLineTest.assertYapfReformatsc              	   C      t d}t d}tj| j|dd1}ttd|g }|  t	j
|ddd}| }W d    n1 s8w   Y  W d    n1 sGw   Y  | || d S )	N,        def foo():
          x = 37
        .        def foo():
            x = 37
        .pysuffix
--in-placer modenewliner   r   r   r8   r)   rs   rt   rr   waitiorR   rS   rQ   r   r   r   r:   r{   rW   r|   r   r   r   testInPlaceReformatting  s   


z'CommandLineTest.testInPlaceReformattingc              	   C      d}d}t j| j|dd2}ttd|g }|  tj|dddd	}|	 }W d    n1 s3w   Y  W d    n1 sBw   Y  | 
|| d S )
Nz


r   r   r   r   rq   r   r   encodingr   r   r8   r)   rs   rt   rr   r   r   rR   rS   rQ   r   r   r   r   testInPlaceReformattingBlank     
z,CommandLineTest.testInPlaceReformattingBlankc              	   C   r   )
Nz

z
r   r   r   r   rq   r   r   r   r   r   r   r   %testInPlaceReformattingWindowsNewLine  r   z5CommandLineTest.testInPlaceReformattingWindowsNewLinec              	   C   r   )	Nzdef foo(): x = 37r   r   r   r   r   r   r   r   r   r   r   r    testInPlaceReformattingNoNewLine  s   


z0CommandLineTest.testInPlaceReformattingNoNewLinec              	   C   s   d}d}t j| j|dd2}ttd|g }|  tj|dddd}|	 }W d    n1 s3w   Y  W d    n1 sBw   Y  | 
|| d S )Nr   r   r   r   r   rq   r   r   r   r   r   r   testInPlaceReformattingEmpty  r   z,CommandLineTest.testInPlaceReformattingEmptyc              	   C   s|   dD ]9\}}t j| j|dd$}tjtdd|g dd}|r!| jn| j}|d| | W d    n1 s6w   Y  qd S )	N))z1==2T)z1 == 2Fr   r   r   z--print-modifiedT)textz
Formatted )r   r8   r)   rs   check_outputrr   rL   ZassertNotIn)r   r   Z
has_changer:   outputcheckr   r   r   testPrintModified  s   z!CommandLineTest.testPrintModifiedc                 C   r   )Nr   r   r   r   r~   r   r   r   r   testReadFromStdin     

z!CommandLineTest.testReadFromStdinc                 C   r   )Nz!        s =   "foo\nbar"
        z        s = "foo\nbar"
        r   r   r   r   r   #testReadFromStdinWithEscapedStrings     

z3CommandLineTest.testReadFromStdinWithEscapedStringsc                 C   s*   t d}t d}| j||dgd d S )N6        def foo(): # trail
            x = 37
        z5        def foo():  # trail
          x = 37
        z--style=yapfrz   r   r   r   r   r   testSetYapfStyle  s   


z CommandLineTest.testSetYapfStylec                 C   j   t d}t d}t d}t| j|}| j||d|gd W d    d S 1 s.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   r8   r)   r~   formatr   r   r   Z
style_file	stylepathr   r   r   testSetCustomStyleBasedOnYapf)  s   



"z-CommandLineTest.testSetCustomStyleBasedOnYapfc                 C   r   )Nzt        a_very_long_statement_that_extends_way_beyond # Comment
        short # This is a shorter statement
        z        a_very_long_statement_that_extends_way_beyond # Comment
        short                                         # This is a shorter statement
        z?        [style]
        spaces_before_comment = 15, 20
        r   r   r   r   r   r   r   %testSetCustomStyleSpacesBeforeComment=  s   



"z5CommandLineTest.testSetCustomStyleSpacesBeforeCommentc                 C   $   t d}t d}| || d S )Nz        if True: pass
        r   r   r   r   r   testReadSingleLineCodeFromStdinP  r   z/CommandLineTest.testReadSingleLineCodeFromStdinc                 C   s   t d}tjd| jdT\}}tj| j|dd0}ztjtd|g |d W n tj	yA } z| 
|jd W Y d }~nd }~ww W d    n1 sLw   Y  W d    d S W d    d S 1 sdw   Y  d S )Nzp        '''The module docstring.'''
        # -*- coding: utf-8 -*-
        def f():
            x = 37
        r   )r   dirnamer   z--diff)rl   rF   )r   r   r   NamedTempFiler)   r8   rs   
check_callrr   CalledProcessErrorrQ   
returncode)r   r   outr   r:   er   r   r   testEncodingVerificationY  s(   
"z(CommandLineTest.testEncodingVerificationc                 C   ,   t d}t d}| j||ddgd d S )Nav          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass


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


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


z-CommandLineTest.testReformattingSpecificLinesc                 C   r   )Nzx        import sys

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

        # Comment
        def some_func(x):
            x = ["badly", "formatted", "line"]
        r   z5-5r   r   r   r   r   r   4testOmitFormattingLinesBeforeDisabledFunctionComment     


zDCommandLineTest.testOmitFormattingLinesBeforeDisabledFunctionCommentc                 C   r   )Na          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

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


        # yapf: disable
        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass
        # yapf: enable
        r   r   r   r   r   testReformattingSkippingLines  s   

z-CommandLineTest.testReformattingSkippingLinesc                 C   r   )Na          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

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

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


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

        def f():
            def e():
                while (xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa' and
                       xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) ==
                       'bbbbbbb'):
                    pass
        r   r   r   r   r   #testReformattingSkippingToEndOfFile  s   

z3CommandLineTest.testReformattingSkippingToEndOfFilec                 C   r   )Na          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

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


        def g():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):  # yapf: disable
                pass
        r   r   r   r   r   "testReformattingSkippingSingleLine     

	z2CommandLineTest.testReformattingSkippingSingleLinec                 C   r   )Nz`        A = set([
            'hello',
            'world',
        ])  # yapf: disable
        r   r   r   r   r   testDisableWholeDataStructure     

z-CommandLineTest.testDisableWholeDataStructurec                 C   r   )Nz        class SplitPenaltyTest(unittest.TestCase):

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

            def testUnbreakable(self):
                self._CheckPenalties(tree, [
                ])  # yapf: disable
        r   r   r   r   r    testDisableButAdjustIndentations  s   

z0CommandLineTest.testDisableButAdjustIndentationsc                 C   r   )Na          def h():
            if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'):
                pass

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


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

        def g():


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

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

        def g():


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

                pass
        r   r   r   z

        if a:     b


        if c:
            to_much      + indent

            same



        #comment

        #   trailing whitespace
        z        if a: b


        if c:
            to_much      + indent

            same



        #comment

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

        '''

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

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



z,CommandLineTest.testDisabledMultilineStringsc                 C   r   )Nz        # yapf: disable
        A = set([
            'hello',
            'world',
        ])
        # yapf: enable
        B = set([
            'hello',
            'world',
        ])  # yapf: disable
        r   z1-10r   r   r   r   r   r   testDisableWhenSpecifyingLines  s   


z.CommandLineTest.testDisableWhenSpecifyingLinesc                 C   r   )Na)          def horrible():
          oh_god()
          why_would_you()
          [
             'do',

              'that',
          ]

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

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

                'that',
            ]

        def still_horrible():
            oh_god()
            why_would_you()
            ['do', 'that']
        r   z14-15r   r   r   r   r   r   "testDisableFormattingInDataLiteral  s   


z2CommandLineTest.testDisableFormattingInDataLiteralc                 C   r   )N          class A(object):
            def aaaaaaaaaaaaa(self):
                c = bbbbbbbbb.ccccccccc('challenge', 0, 1, 10)
                self.assertEqual(
                    ('ddddddddddddddddddddddddd',
             'eeeeeeeeeeeeeeeeeeeeeeeee.%s' %
                     c.ffffffffffff),
             gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                iiiii = jjjjjjjjjjjjjj.iiiii
                  class A(object):
            def aaaaaaaaaaaaa(self):
                c = bbbbbbbbb.ccccccccc('challenge', 0, 1, 10)
                self.assertEqual(('ddddddddddddddddddddddddd',
                                  'eeeeeeeeeeeeeeeeeeeeeeeee.%s' % c.ffffffffffff),
                                 gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                iiiii = jjjjjjjjjjjjjj.iiiii
        r   z4-7r   r   r   r   r   r   :testRetainVerticalFormattingBetweenDisabledAndEnabledLines     

	
zJCommandLineTest.testRetainVerticalFormattingBetweenDisabledAndEnabledLinesc                 C   r   )Nz        class A(object):
            def aaaaaaaaaaaaa(self):
                pass


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

        SCOPES = [
            'hello world'  # This is a comment.
        ]
        r   r   r   r   r   r   r   *testTrailingCommentsWithDisabledFormatting  r   z:CommandLineTest.testTrailingCommentsWithDisabledFormattingc                 C   X   d}d}d}t | j|}| j||d|gd W d    d S 1 s%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   r8   r)   r~   r   r   r   r   Zstyle_contentsr   r   r   r   testUseTabs  s   
"zCommandLineTest.testUseTabsc                 C   r   )Nz&def f():
  return ['hello', 'world',]
z2def f():
	return [
	    'hello',
	    'world',
	]
r   r   r   r   r   r   r   r   testUseTabsWith  s   
"zCommandLineTest.testUseTabsWithc                 C   r   )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   r   r   r   &testUseTabsContinuationAlignStyleFixed-     	
"z6CommandLineTest.testUseTabsContinuationAlignStyleFixedc                 C   r   )Nr   zNdef foo_function(arg1, arg2,
					arg3):
	return [
			'hello',
			'world',
	]
z[style]
based_on_style = yapf
USE_TABS = true
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = valign-right
r   r   r   r   r   r   r   ,testUseTabsContinuationAlignStyleVAlignRightI  r   z<CommandLineTest.testUseTabsContinuationAlignStyleVAlignRightc                 C   r   )Nr   zjdef foo_function(
        arg1, arg2, arg3):
    return [
            'hello',
            'world',
    ]
zz[style]
based_on_style = yapf
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = fixed
r   r   r   r   r   r   r   (testUseSpacesContinuationAlignStyleFixede     
"z8CommandLineTest.testUseSpacesContinuationAlignStyleFixedc                 C   r   )Nr   zudef foo_function(arg1, arg2,
                    arg3):
    return [
            'hello',
            'world',
    ]
z[style]
based_on_style = yapf
COLUMN_LIMIT=32
INDENT_WIDTH=4
CONTINUATION_INDENT_WIDTH=8
CONTINUATION_ALIGN_STYLE = valign-right
r   r   r   r   r   r   r   .testUseSpacesContinuationAlignStyleVAlignRight  r   z>CommandLineTest.testUseSpacesContinuationAlignStyleVAlignRightc                 C   s   t d}t d}tj| jd1\}}tjtdg |tjtjd}|	 \}}| 
|d | j||d|gd W d    d S 1 sEw   Y  d S )	Nz3        def foo_function():
          pass
        z5        def foo_function():
            pass
        )r   z--style-help)rl   rm   rn   rp   r   r   )r   r   r   r   r)   rs   rt   rr   ru   rv   rQ   r~   r   )r   r   r   Z	stylefiler   r{   r   r}   r   r   r   testStyleOutputRoundTrip  s$   


"z(CommandLineTest.testStyleOutputRoundTripc                 C   r   )Nzq        A = 42


        # A comment
        def x():
            pass
        def _():
            pass
        r   r   r   r   r   r   r   r   testSpacingBeforeComments  r   z)CommandLineTest.testSpacingBeforeCommentsc                 C   r   )Na5          A=42

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

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

    3
]
)r   r	   r   z1-100r   r   r   r   r   r   testDisableWithLineRanges	  s   		
z)CommandLineTest.testDisableWithLineRanges)NN)7r    r!   r"   __doc__classmethodrj   rk   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rg     sp    



		'P(6"$rg   c                   @   s    e Zd ZdZdd Zdd ZdS )BadInputTestz,Test yapf's behaviour when passed bad input.c                 C      d}|  tjtj| d S )Nz  a = 1
rT   r   Z	YapfErrorr   r   r   r3   r   r   r   testBadSyntax%     zBadInputTest.testBadSyntaxc                 C   r   )Nzx = """hello
r   r   r   r   r   testBadCode)  r   zBadInputTest.testBadCodeN)r    r!   r"   r   r   r  r   r   r   r   r   "  s    r   c                   @   (   e Zd Zedd Zdd Zdd ZdS )DiffIndentTestc                  C   s   t  } d| d< d| d< | S )NrI   ZINDENT_WIDTHZCONTINUATION_INDENT_WIDTHr   ZCreatePEP8StyleZmy_styler   r   r   	_OwnStyle0  s   zDiffIndentTest._OwnStylec                 C   ,   t j|t|  d\}}| || d S Nr   r   r   r   SetGlobalStyler  rQ   r   r   r   r   r   7     
zDiffIndentTest._Checkc                 C   r   )Nz:        for i in range(5):
         print('bar')
         z>        for i in range(5):
           print('bar')
           r   r   r   r   r   r   <  r   zDiffIndentTest.testSimpleN)r    r!   r"   staticmethodr  r   r   r   r   r   r   r  .  s
    
r  c                   @   sx   e Zd Zedd Zdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )'HorizontallyAlignedTrailingCommentsTestc                  C   s   t  } g d| d< | S )N)      #   ZSPACES_BEFORE_COMMENTr  r  r   r   r   r  J  s   z1HorizontallyAlignedTrailingCommentsTest._OwnStylec                 C   r  r  )r   r   r   r
  r  r   r   r   r   r   r   T  r  z.HorizontallyAlignedTrailingCommentsTest._Checkc                 C   r   )Nz        foo = '1' # Aligned at first list value

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

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

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

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

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

        foo = '4______________________<35>' # Aligned beyond list values
        r   r   r   r   r   r   Y  s   

		z2HorizontallyAlignedTrailingCommentsTest.testSimplec                 C   r   )Nz        func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                            # Line 5
                                            # Line 6
        z        func(1)       # Line 1
        func(2)       # Line 2
                      # Line 3
        func(3)       # Line 4
                      # Line 5
                      # Line 6
        r   r   r   r   r   	testBlockn     

z1HorizontallyAlignedTrailingCommentsTest.testBlockc                 C   r   )Na          func(1)     # Line 1
        func___________________(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                            # Line 5
                                            # Line 6
        a:          func(1)                           # Line 1
        func___________________(2)        # Line 2
                                          # Line 3
        func(3)                           # Line 4
                                          # Line 5
                                          # Line 6
        r   r   r   r   r   testBlockWithLongLine  r  z=HorizontallyAlignedTrailingCommentsTest.testBlockWithLongLinec                 C   r   )Na          func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                        # Line 5
                                    # Line 6

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


        def Func():
            pass
        r   r   r   r   r   testBlockFuncSuffix  s   

z;HorizontallyAlignedTrailingCommentsTest.testBlockFuncSuffixc                 C   r   )Nah          func(1)     # Line 1
        func(2) # Line 2
        # Line 3
        func(3)                             # Line 4
                                        # Line 5 - SpliceComments makes this part of the previous block
                                    # Line 6

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

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


z>HorizontallyAlignedTrailingCommentsTest.testBlockCommentSuffixc                 C   r   )Na          if True:
            func(1)     # Line 1
            func(2) # Line 2
            # Line 3
            func(3)                             # Line 4
                                                # Line 5 - SpliceComments makes this a new block
                                                # Line 6

                                                # Aligned with Func

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

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

            # Aligned with Func


            def Func():
                pass
        r   r   r   r   r   testBlockIndentedFuncSuffix  s   

zCHorizontallyAlignedTrailingCommentsTest.testBlockIndentedFuncSuffixc                 C   r   )NaV          if True:
            func(1)     # Line 1
            func(2) # Line 2
            # Line 3
            func(3)                             # Line 4
                                                # Line 5
                                                # Line 6

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

            # Not aligned
        r   r   r   r   r   testBlockIndentedCommentSuffix     

zFHorizontallyAlignedTrailingCommentsTest.testBlockIndentedCommentSuffixc                 C   r   )Na          if True:
            if True:
                if True:
                    func(1)     # Line 1
                    func(2) # Line 2
                    # Line 3
                    func(3)                             # Line 4
                                                        # Line 5
                                                        # Line 6

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

                    # Not aligned
        r   r   r   r   r   testBlockMultiIndented  s   

z>HorizontallyAlignedTrailingCommentsTest.testBlockMultiIndentedc                 C   r   )Nz        def MyFunc(
            arg1,   # Desc 1
            arg2,   # Desc 2
            a_longer_var_name,  # Desc 3
            arg4,
            arg5,   # Desc 5
            arg6,
        ):
            pass
        a           def MyFunc(
            arg1,               # Desc 1
            arg2,               # Desc 2
            a_longer_var_name,  # Desc 3
            arg4,
            arg5,               # Desc 5
            arg6,
        ):
            pass
        r   r   r   r   r   testArgs  r  z0HorizontallyAlignedTrailingCommentsTest.testArgsc                 C   r   )Nz        a() # comment 1
        b() # comment 2

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

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

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

        e()           # comment 5
        f()           # comment 6
        r   r   r   r   r   testDisableBlock5  s   

z8HorizontallyAlignedTrailingCommentsTest.testDisableBlockc                 C   r   )Nz        short # comment 1
        do_not_touch1 # yapf: disable
        do_not_touch2   # yapf: disable
        a_longer_statement # comment 2
        z        short                   # comment 1
        do_not_touch1 # yapf: disable
        do_not_touch2   # yapf: disable
        a_longer_statement      # comment 2
        r   r   r   r   r   testDisabledLineP  r   z8HorizontallyAlignedTrailingCommentsTest.testDisabledLineN)r    r!   r"   r  r  r   r   r  r  r  r  r  r  r  r  r  r  r   r   r   r   r  H  s    
	!r  c                   @   r  )"_SpacesAroundDictListTupleTestImplc                  C   s$   t  } d| d< d| d< d| d< | S )NTZDISABLE_ENDING_COMMA_HEURISTICFZ SPLIT_ALL_COMMA_SEPARATED_VALUESZ%SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATEDr  r  r   r   r   r  b  s
   z,_SpacesAroundDictListTupleTestImpl._OwnStylec                 C   r  r  r	  r   r   r   r   r   j  r  z)_SpacesAroundDictListTupleTestImpl._Checkc                 C   s
   d | _ d S r%   )ZmaxDiffr*   r   r   r   r+   o  s   
z(_SpacesAroundDictListTupleTestImpl.setUpN)r    r!   r"   r  r  r   r+   r   r   r   r   r  `  s
    
r  c                       (   e Zd Ze fddZdd Z  ZS )SpacesAroundDictTestc                       t t|  }d|d< |S )NTZSPACES_AROUND_DICT_DELIMITERS)superr  r  ri   r   	__class__r   r   r  u     zSpacesAroundDictTest._OwnStylec                 C   r   )Na?        {1 : 2}
      {k:v for k, v in other.items()}
      {k for k in [1, 2, 3]}

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

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

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

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

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

      # Dict settings should not impact lists or tuples
      [1, 2]
      (3, 4)
      r   r   r   r   r   testStandard|  s   

z!SpacesAroundDictTest.testStandardr    r!   r"   r   r  r&  __classcell__r   r   r#  r   r  s      r  c                       r  )SpacesAroundListTestc                    r   )NTZSPACES_AROUND_LIST_DELIMITERS)r!  r*  r  r"  r#  r   r   r    r%  zSpacesAroundListTest._OwnStylec                 C   r   )Na        [a,b,c]
      [4,5,]
      [6, [7, 8], 9]
      [v for v in [1,2,3] if v & 1]

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

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

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

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

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

      # List settings should not impact dicts or tuples
      {a: b}
      (1, 2)
      r   r   r   r   r   r&    s   

z!SpacesAroundListTest.testStandardr'  r   r   r#  r   r*    r)  r*  c                       r  )SpacesAroundTupleTestc                    r   )NTZSPACES_AROUND_TUPLE_DELIMITERS)r!  r+  r  r"  r#  r   r   r    r%  zSpacesAroundTupleTest._OwnStylec                 C   r   )Na        (0, 1)
      (2, 3)
      (4, 5, 6,)
      func((7, 8), 9)

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

      (0, 1) # yapf: disable

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

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

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

      (0, 1) # yapf: disable

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

      # Tuple settings should not impact dicts or lists
      {a: b}
      [3, 4]
      r   r   r   r   r   r&    s   

z"SpacesAroundTupleTest.testStandardr'  r   r   r#  r   r+    r)  r+  __main__))r   r   loggingosr.   rs   sysr'   r   Zunittestr   Z yapf_third_party._ylib2to3.pgen2r   Zyapf.yapflibr   r   r   Z	yapftestsr   r   pathr   abspath__file__ZROOT_DIR
executablerr   ZYAPFTestr
   ZTestCaser#   rg   r   r  r  r  r  r*  r+  r    mainr   r   r   r   <module>   sZ     U           08<