
    ?d/                         d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d dej                        Z	e
dk(  r ej                          yy)	z(Style config tests for yapf.reformatter.    N)reformatter)style)yapf_test_helperc                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)TestsForStyleConfigc                 .    t         j                  | _        y )N)r   DEFAULT_STYLEcurrent_style)selfs    I/usr/lib/python3/dist-packages/yapftests/reformatter_style_config_test.pysetUpzTestsForStyleConfig.setUp   s    ,,D    c                    	 t        j                  t        j                                t        j                  d      }t        j                  d      }t        j                  |      }| j                  |t        j                  |             t        j                  t        j                                | j                  t         _        t        j                  d      }t        j                  d      }t        j                  |      }| j                  |t        j                  |             y # t        j                  t        j                                | j                  t         _        w xY w)Nz?          for i in range(5):
           print('bar')
          z@          for i in range(5):
            print('bar')
          z9        for i in range(5):
         print('bar')
        z<        for i in range(5):
            print('bar')
        )r   SetGlobalStyleCreateYapfStyletextwrapdedentr   ParseAndUnwrapassertCodeEqualr   ReformatCreatePEP8Styler
   r	   )r   unformatted_codeexpected_formatted_codelliness       r   testSetGlobalStylez&TestsForStyleConfig.testSetGlobalStyle   s#   /50023! *  !) 1 !  ../?@f
2&//79 50023 ..e (  'oo /  ,,-=>F0+2F2Fv2NO 50023 ..es   BD. .>E,c                 J   	 t        j                         }t        j                  d      |d<   t        j                  |       t	        j
                  d      }t	        j
                  d      }t        j                  |      }| j                  |t        j                  |             t        j                  t        j                                | j                  t         _        y # t        j                  t        j                                | j                  t         _        w xY w)Nz*,/*NO_SPACES_AROUND_SELECTED_BINARY_OPERATORSz>          a = 1+2 * 3 - 4 / 5
          b = '0' * 1
          z:          a = 1 + 2*3 - 4/5
          b = '0'*1
          )r   r   _StringSetConverterr   r   r   r   r   r   r   r   r
   r	   )r   sympy_styler   r   r   s        r   testOperatorNoSpaceStylez,TestsForStyleConfig.testOperatorNoSpaceStyle;   s    /))+k!!%( >?;'! *  !) 1 !
  ../?@f
2&//79 50023 ..e 50023 ..es   B%C$ $>D"c                 $   	 t        j                         }d|d<   t        j                  |       t        j                  d      }t        j                  d      }t        j                  |      }| j                  |t        j                  |             t        j                  t        j                                | j                  t         _        y # t        j                  t        j                                | j                  t         _        w xY w)NT ARITHMETIC_PRECEDENCE_INDICATIONa            1+2
          (1 + 2) * (3 - (4 / 5))
          a = 1 * 2 + 3 / 4
          b = 1 / 2 - 3 * 4
          c = (1 + 2) * (3 - 4)
          d = (1 - 2) / (3 + 4)
          e = 1 * 2 - 3
          f = 1 + 2 + 3 + 4
          g = 1 * 2 * 3 * 4
          h = 1 + 2 - 3 + 4
          i = 1 * 2 / 3 * 4
          j = (1 * 2 - 3) + 4
          k = (1 * 2 * 3) + (4 * 5 * 6 * 7 * 8)
          af            1 + 2
          (1+2) * (3 - (4/5))
          a = 1*2 + 3/4
          b = 1/2 - 3*4
          c = (1+2) * (3-4)
          d = (1-2) / (3+4)
          e = 1*2 - 3
          f = 1 + 2 + 3 + 4
          g = 1 * 2 * 3 * 4
          h = 1 + 2 - 3 + 4
          i = 1 * 2 / 3 * 4
          j = (1*2 - 3) + 4
          k = (1*2*3) + (4*5*6*7*8)
          r   r   r   r   r   r   r   r   r   r   r
   r	   )r   pep8_with_precedencer   r   r   s        r   testOperatorPrecedenceStylez/TestsForStyleConfig.testOperatorPrecedenceStyleQ   s    (/"224AE=>/0! *  !) 1 !   ../?@f
2&//79 50023 ..e 50023 ..es   BC >Dc                    	 t        j                         }d|d<   d|d<   t        j                  |       t        j                  d      }t        j                  |      }| j                  |t        j                  |             t        j                  t        j                                | j                  t         _        y # t        j                  t        j                                | j                  t         _        w xY w)NFSPLIT_BEFORE_FIRST_ARGUMENTSPLIT_BEFORE_NAMED_ASSIGNSa            # Example from in-code MustSplit comments
          foo = outer_function_call(fitting_inner_function_call(inner_arg1, inner_arg2),
                                    outer_arg1, outer_arg2)

          foo = outer_function_call(
              not_fitting_inner_function_call(inner_arg1, inner_arg2), outer_arg1,
              outer_arg2)

          # Examples Issue#424
          a_super_long_version_of_print(argument1, argument2, argument3, argument4,
                                        argument5, argument6, argument7)

          CREDS_FILE = os.path.join(os.path.expanduser('~'),
                                    'apis/super-secret-admin-creds.json')

          # Examples Issue#556
          i_take_a_lot_of_params(arg1, param1=very_long_expression1(),
                                 param2=very_long_expression2(),
                                 param3=very_long_expression3(),
                                 param4=very_long_expression4())

          # Examples Issue#590
          plt.plot(numpy.linspace(0, 1, 10), numpy.linspace(0, 1, 10), marker="x",
                   color="r")

          plt.plot(veryverylongvariablename, veryverylongvariablename, marker="x",
                   color="r")
          r#   r   pep8_no_split_before_firstformatted_coder   s       r   $testNoSplitBeforeFirstArgumentStyle1z8TestsForStyleConfig.testNoSplitBeforeFirstArgumentStyle1|   s    &/#(#8#8#: BG !>?AF !=>56 ( n:  ..~>f
>;+?+?+GH50023 ..e 50023 ..e   BC >C?c                    	 t        j                         }d|d<   d|d<   t        j                  |       t        j                  d      }t        j                  |      }| j                  |t        j                  |             t        j                  t        j                                | j                  t         _        y # t        j                  t        j                                | j                  t         _        w xY w)NFr'   Tr(   a            # Examples Issue#556
          i_take_a_lot_of_params(arg1,
                                 param1=very_long_expression1(),
                                 param2=very_long_expression2(),
                                 param3=very_long_expression3(),
                                 param4=very_long_expression4())

          # Examples Issue#590
          plt.plot(numpy.linspace(0, 1, 10),
                   numpy.linspace(0, 1, 10),
                   marker="x",
                   color="r")

          plt.plot(veryverylongvariablename,
                   veryverylongvariablename,
                   marker="x",
                   color="r")
          r#   r)   s       r   $testNoSplitBeforeFirstArgumentStyle2z8TestsForStyleConfig.testNoSplitBeforeFirstArgumentStyle2   s    /#(#8#8#: BG !>?AE !=>56 ( n&  ..~>f
>;+?+?+GH50023 ..e 50023 ..er-   N)	__name__
__module____qualname__r   r   r    r%   r,   r/    r   r   r   r      s#    -P:/,)/V'/R/r   r   __main__)__doc__r   unittestyapf.yapflibr   r   	yapftestsr   YAPFTestr   r0   mainr3   r   r   <module>r;      sI    /   $  &i/*33 i/X z(--/ r   