
    `N`#                         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 ddlmZ  G d dej	                  Z
ed	k    r ej                     dS dS )
z%Tests for yapf.blank_line_calculator.    N)reformatter)style)yapf_api)yapf_test_helperc                   r    e Zd Zed             Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd ZdS )BasicBlankLineCalculatorTestc                 P    t          j        t          j                               d S )N)r   SetGlobalStyleCreateYapfStyle)clss    Dlib/python3.11/site-packages/yapftests/blank_line_calculator_test.py
setUpClassz'BasicBlankLineCalculatorTest.setUpClass   s"    	.0011111    c                     t          j        d          }t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nz;        @bork()

        def foo():
          pass
        z:        @bork()
        def foo():
          pass
        textwrapdedentr   ParseAndUnwrapassertCodeEqualr   Reformatselfunformatted_codeexpected_formatted_codeuwliness       r   testDecoratorsz+BasicBlankLineCalculatorTest.testDecorators    sm     (   'o /  
 -.>??G0+2Fw2O2OPPPPPr   c                     t          j        d          }t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nz        import sys
        @bork()

        def foo():
          pass
        @fork()

        class moo(object):
          @bar()
          @baz()

          def method(self):
            pass
        z        import sys


        @bork()
        def foo():
          pass


        @fork()
        class moo(object):

          @bar()
          @baz()
          def method(self):
            pass
        r   r   s       r   testComplexDecoratorsz2BasicBlankLineCalculatorTest.testComplexDecorators/   sm     (   'o /  " -.>??G0+2Fw2O2OPPPPPr   c                     t          j        d          }t          j        d          }t          j        |          }|                     |t          j        |                     d S )Na>          def foo():
          pass
        top_level_code = True
        class moo(object):
          def method_1(self):
            pass
          ivar_a = 42
          ivar_b = 13
          def method_2(self):
            pass
        try:
          raise Error
        except Error as error:
          pass
        aG          def foo():
          pass


        top_level_code = True


        class moo(object):

          def method_1(self):
            pass

          ivar_a = 42
          ivar_b = 13

          def method_2(self):
            pass


        try:
          raise Error
        except Error as error:
          pass
        r   r   s       r    testCodeAfterFunctionsAndClassesz=BasicBlankLineCalculatorTest.testCodeAfterFunctionsAndClassesS   sm     (    'o /  2 -.>??G0+2Fw2O2OPPPPPr   c                     t          j        d          }t          j        d          }t          j        |          }|                     |t          j        |                     d S )Na2          # This is the first comment
        # And it's multiline

        # This is the second comment

        def foo():
          pass

        # multiline before a
        # class definition

        # This is the second comment

        class qux(object):
          pass


        # An attached comment.
        class bar(object):
          '''class docstring'''
          # Comment attached to
          # function
          def foo(self):
            '''Another docstring.'''
            # Another multiline
            # comment
            pass
        a6          # This is the first comment
        # And it's multiline

        # This is the second comment


        def foo():
          pass


        # multiline before a
        # class definition

        # This is the second comment


        class qux(object):
          pass


        # An attached comment.
        class bar(object):
          '''class docstring'''

          # Comment attached to
          # function
          def foo(self):
            '''Another docstring.'''
            # Another multiline
            # comment
            pass
        r   r   s       r   testCommentSpacingz/BasicBlankLineCalculatorTest.testCommentSpacing   sn     (  : 'o  /    B -.>??G0+2Fw2O2OPPPPPr   c                     t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nzu        class foo(object):

          # pylint: disable=invalid-name
          def f(self):
            pass
        r   r   coder   s      r   testCommentBeforeMethodz4BasicBlankLineCalculatorTest.testCommentBeforeMethod   sQ    ?   D -d33G{3G<<=====r   c                     t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nz[        """Test."""

        # Comment


        class Foo(object):
          pass
        r   r$   s      r   testCommentsBeforeClassDefsz8BasicBlankLineCalculatorTest.testCommentsBeforeClassDefs   sQ    ?   D -d33G{3G<<=====r   c                 F   t          j        d          }t          j        |          }|                     |t          j        |                     t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nze        # The @foo operator adds bork to a().
        @foo()
        def a():
          pass
        zO        # Hello world


        @foo()
        def a():
          pass
        r   r$   s      r   testCommentsBeforeDecoratorz8BasicBlankLineCalculatorTest.testCommentsBeforeDecorator   s    ?   D -d33G{3G<<===?   D -d33G{3G<<=====r   c                     t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nap          class _():

          def _():
            pass

          @pytest.mark.xfail(reason="#709 and #710")
          # also
          #@pytest.mark.xfail(setuptools.tests.is_ascii,
          #    reason="https://github.com/pypa/setuptools/issues/706")
          def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch):
            pass
        r   r$   s      r   testCommentsAfterDecoratorz7BasicBlankLineCalculatorTest.testCommentsAfterDecorator   sQ    ?   D -d33G{3G<<=====r   c                     t          j        d          }t          j        d          }t          j        |          }|                     |t          j        |                     d S )Nz      class DeployAPIClient(object):
          class Error(Exception): pass

          class TaskValidationError(Error): pass

          class DeployAPIHTTPError(Error): pass
        z      class DeployAPIClient(object):

        class Error(Exception):
          pass

        class TaskValidationError(Error):
          pass

        class DeployAPIHTTPError(Error):
          pass
        r   r   s       r   testInnerClassesz-BasicBlankLineCalculatorTest.testInnerClasses   sm     (   'o /   -.>??G0+2Fw2O2OPPPPPr   c                     t          j        d          }t          j        d          }t          j        |ddg          \  }}|                     ||           |                     |           d S )Nz        def A():
          pass

        def B():  # 4
          pass  # 5

        def C():
          pass
        def D():  # 9
          pass  # 10
        def E():
          pass
        z        def A():
          pass


        def B():  # 4
          pass  # 5


        def C():
          pass


        def D():  # 9
          pass  # 10


        def E():
          pass
        )      )	   
   linesr   r   r   
FormatCoder   
assertTruer   r   r   r%   changeds        r   testLinesOnRangeBoundaryz5BasicBlankLineCalculatorTest.testLinesOnRangeBoundary  s     (   'o /  ( ' 13 3 3MD'0$777OOGr   c                     t          j        d          }t          j        d          }t          j        |dg          \  }}|                     ||           |                     |           d S )Nzx        def A():
          pass



        def B():  # 6
          pass  # 7



        def C():
          pass
        )      r4   )r   r   r   r7   r   assertFalser9   s        r    testLinesRangeBoundaryNotOutsidez=BasicBlankLineCalculatorTest.testLinesRangeBoundaryNotOutside@  s     (   'o /   '(8IIIMD'0$777Wr   c                     t          j        d          }t          j        d          }t          j        |dg          \  }}|                     ||           |                     |           d S )Nzy        def A():
          pass



        def B():  # 6
          pass  # 7




        def C():
          pass
        zv        def A():
          pass


        def B():  # 6
          pass  # 7


        def C():
          pass
        )r1   r2   r4   r6   r9   s        r   testLinesRangeRemovez1BasicBlankLineCalculatorTest.testLinesRangeRemovea  s     (   'o /   '(8IIIMD'0$777OOGr   c                     t          j        d          }t          j        d          }t          j        |dg          \  }}|                     ||           |                     |           d S )Nzz        def A():
          pass




        def B():  # 7
          pass  # 8




        def C():
          pass
        zx        def A():
          pass



        def B():  # 7
          pass  # 8



        def C():
          pass
        )r=   r2   r4   r6   r9   s        r   testLinesRangeRemoveSomez5BasicBlankLineCalculatorTest.testLinesRangeRemoveSome  s     (    'o /   '(8IIIMD'0$777OOGr   N)__name__
__module____qualname__classmethodr   r   r   r    r"   r&   r(   r*   r,   r.   r;   r@   rB   rD    r   r   r   r      s       2 2 ;2Q Q Q"Q "Q "QH+Q +Q +QZ@Q @Q @QD	> 	> 	>> > >> > >*> > >"Q Q Q0& & &P  B  @! ! ! ! !r   r   __main__)__doc__r   unittestyapf.yapflibr   r   r   	yapftestsr   YAPFTestr   rE   mainrI   r   r   <module>rQ      s    , +   $ $ $ $ $ $       ! ! ! ! ! ! & & & & & &H H H H H#3#< H H HV z(-///// r   