
    j81                         S SK r S SKJr  S SKJrJrJrJr  S SK	J
r  S SKJ
r  S SKJ
r  S SKJrJr   " S S5      r " S S	\5      r
 " S
 S\\5      r " S S\\5      r " S S\\5      rg)    N)messages)PYPYDoctestScopeFunctionScopeModuleScope)Test)TestCaseskipc                   2   ^  \ rS rSrSrS rU 4S jrSrU =r$ )_DoctestMixin   Tc                 Z   / n[         R                  " U5      R                  5        H  nUR                  5       S:X  a  OUR	                  S5      (       d  UR	                  S5      (       dx  UR	                  S5      (       db  UR	                  S5      (       dL  UR	                  S5      (       d6  UR	                  S5      (       d   U(       a  US   R	                  S	5      (       a  S
U-  nOSU-  nUR                  U5        M     [         R                  " S5      nUSR                  U5      -  $ )N  zexcept:zexcept zfinally:zelse:zelif )z>>> @z... @z... %sz>>> %szo            def doctest_something():
                """
                   %s
                """
            z
       )textwrapdedent
splitlinesstrip
startswithappendjoin)selfinputlineslinedoctestificators        S/var/www/html/KUNJ/venv/lib/python3.13/site-packages/pyflakes/test/test_doctests.py
doctestify_DoctestMixin.doctestify   s    OOE*557Dzz|r!//#&&//),,//),,//*--//'**//'**U2Y112DEE$$LL 8 #// +  !1!1%!888    c                 J   > [         TU ]  " U R                  U5      /UQ70 UD6$ )N)superflakesr   )r   r   argskw	__class__s       r   r$   _DoctestMixin.flakes,   s%    w~dooe4BtBrBBr!    )	__name__
__module____qualname____firstlineno__withDoctestr   r$   __static_attributes____classcell__)r'   s   @r   r   r      s    K90C Cr!   r   c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 r\" S5      S 5       rS rS rS rS rS rS rS rS rS rS rS rS rSrg)r   0   Tc                 <   U R                  S5      nUR                  nU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [
        L d  M  UPM     nnU R                  [        U5      S5        U R                  [        U5      S5        US   nUS   nU R                  U[        5        U R                  U[        5        U R                  U[
        5        U R                  U[        5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  [        U5      S5        U R                  SUS   5        gs  snf s  snf s  snf )	z-Check that a doctest is given a DoctestScope.z
        m = None

        def doctest_stuff():
            '''
                >>> d = doctest_stuff()
            '''
            f = m
            return f
           r   mdoctest_stuffdfN)r$   
deadScopesr'   r   r   r   assertEquallenassertIsInstanceassertNotIsInstanceassertIn	r   checkerscopesscopemodule_scopesdoctest_scopesfunction_scopesmodule_scopedoctest_scopes	            r   test_scope_classTest.test_scope_class4   s   ++ 	 	 ##%I%eK)GEv 	 I  &J%eL)HEv 	 J  &K%eM)IEv 	 K 	]+Q/^,a0$Q'&q)m\:m[9  >  |<c<(o|4c=)_-q1c?1-.1IJKs"   FFF"F.FFc                    U R                  S5      nUR                  nU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [
        L d  M  UPM     nnU R                  [        U5      S5        U R                  [        U5      S5        US   nUS   nU R                  SU5        U R                  SU5        U R                  SU5        U R                  [        U5      S5        U R                  SUS   5        U R                  S	US   5        g
s  snf s  snf s  snf )z'Check that nested doctests are ignored.a  
        m = None

        def doctest_stuff():
            '''
                >>> def function_in_doctest():
                ...     """
                ...     >>> ignored_undefined_name
                ...     """
                ...     df = m
                ...     return df
                ...
                >>> function_in_doctest()
            '''
            f = m
            return f
        r4   r   r5   r6   function_in_doctest   r8   dfN)	r$   r9   r'   r   r   r   r:   r;   r>   r?   s	            r   test_nested_doctest_ignored Test.test_nested_doctest_ignored\   sS   ++  $ ##%I%eK)GEv 	 I  &J%eL)HEv 	 J  &K%eM)IEv 	 K 	]+Q/^,a0$Q'&q)c<(o|4+];_-q1c?1-.dOA./)IJKs"   EEE"E.EEc                    U R                  S5      nUR                  nU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [        L d  M  UPM     nnU Vs/ s H  o3R                  [
        L d  M  UPM     nnU R                  [        U5      S5        U R                  [        U5      S5        US   nUS   nU R                  SU5        U R                  SU5        U R                  [        U5      S5        U R                  SUS   5        U R                  SUS   5        U R                  S	US   5        U R                  S	U5        g
s  snf s  snf s  snf )z;Check that global in doctest does not pollute module scope.a[  
        def doctest_stuff():
            '''
                >>> def function_in_doctest():
                ...     global m
                ...     m = 50
                ...     df = 10
                ...     m = df
                ...
                >>> function_in_doctest()
            '''
            f = 10
            return f

        r4   r   r6   rK   rL   r8   rM   r5   N)
r$   r9   r'   r   r   r   r:   r;   r>   assertNotInr?   s	            r   "test_global_module_scope_pollution'Test.test_global_module_scope_pollution   sh   ++    ##%I%eK)GEv 	 I  &J%eL)HEv 	 J  &K%eM)IEv 	 K 	]+Q/^,a0$Q'&q)o|4+];_-q1c?1-.dOA./c?1-.l+-IJKs"   E!E!E&"E&.E+E+c                 D    U R                  S[        R                  5        g )Nzn
        global m

        def doctest_stuff():
            '''
                >>> m
            '''
        r$   r5   UndefinedNamer   s    r   test_global_undefinedTest.test_global_undefined   s      __	r!   c                 b    U R                  S[        R                  [        R                  5        g)z*Doctest within nested class are processed.a  
        class C:
            class D:
                '''
                    >>> m
                '''
                def doctest_stuff(self):
                    '''
                        >>> m
                    '''
                    return 1
        NrU   rW   s    r   test_nested_classTest.test_nested_class   s"      __aoo	/r!   c                 &    U R                  S5        g)z<Doctest module does not process doctest in nested functions.a=  
        def doctest_stuff():
            def inner_function():
                '''
                    >>> syntax error
                    >>> inner_function()
                    1
                    >>> m
                '''
                return 1
            m = inner_function()
            return m
        Nr$   rW   s    r   test_ignore_nested_function Test.test_ignore_nested_function   s     	  	r!   c                 D    U R                  S[        R                  5        g)z#Doctest may not access class scope.z
        class C:
            def doctest_stuff(self):
                '''
                    >>> m
                '''
                return 1
            m = 1
        NrU   rW   s    r   test_inaccessible_scope_class"Test.test_inaccessible_scope_class   s      __	r!   c                 &    U R                  S5        g )Nzr
        import foo

        def doctest_stuff():
            '''
                >>> foo
            '''
        r^   rW   s    r   test_importBeforeDoctestTest.test_importBeforeDoctest   s      	r!   todoc                 D    U R                  S[        R                  5        g )Nz
        import foo

        def doctest_stuff():
            """
                >>> import foo
                >>> foo
            """

        foo
        )r$   r5   RedefinedWhileUnusedrW   s    r   test_importBeforeAndInDoctest"Test.test_importBeforeAndInDoctest   s     
 ##
	%r!   c                 &    U R                  S5        g )Nz
        def doctest_stuff():
            """
                >>> import foo
                >>> foo
            """

        import foo
        foo()
        r^   rW   s    r   test_importInDoctestAndAfter!Test.test_importInDoctestAndAfter       	 		r!   c                     U R                  S[        R                  5      R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nzg

        def doctest_stuff():
            """
                >>> x # line 5
            """

        r         r$   r5   rV   r   r:   linenocolr   excs     r   test_offsetInDoctestsTest.test_offsetInDoctests  V    kk  __ 'hq* 	Q'"%r!   c                     U R                  S[        R                  5      R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nzo

        def doctest_stuff():
            """
                >>> lambda: x # line 5
            """

        r   rq      rs   rv   s     r   test_offsetInLambdasInDoctests#Test.test_offsetInLambdasInDoctests  rz   r!   c                     U R                  S[        R                  5      R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nzm

        def doctest_stuff():
            """
                >>> x = 5
            """

        x

        r      rs   rv   s     r   test_offsetAfterDoctestsTest.test_offsetAfterDoctests(  sV    kk 	 __	 'hq	* 	Q'!$r!   c                    U R                  S[        R                  [        R                  [        R                  5      R                  nUS   nU R	                  UR
                  S5        [        (       d  U R	                  UR                  S5        OU R	                  UR                  S5        US   nU R	                  UR
                  S5        [        (       a  U R	                  UR                  S5        OU R	                  UR                  S	5        US
   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nz
            def doctest_stuff():
                """
                    >>> from # line 4
                    >>>     fortytwo = 42
                    >>> except Exception:
                """
            r            r4   rq      r   rL      )r$   r5   DoctestSyntaxErrorr   r:   rt   r   ru   r   
exceptionsrw   s      r   test_syntaxErrorInDoctestTest.test_syntaxErrorInDoctest6  s   [[       " #+( 	 mQ'tSWWb)SWWb)
 mQ'4SWWb)SWWb)mQ'"%r!   c                     U R                  S[        R                  5      R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )Nz|
        def doctest_stuff():
            """
                >>> if True:
                ... pass
            """
        r   rq   r   )r$   r5   r   r   r:   rt   ru   rv   s     r   test_indentationErrorInDoctest#Test.test_indentationErrorInDoctestW  sX    kk  !!# $,8A/ 	Q'"%r!   c                 Z   U R                  S[        R                  [        R                  5      R                  u  pU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        g )Nz
            def doctest_stuff(arg1,
                              arg2,
                              arg3):
                """
                    >>> assert
                    >>> this
                """
            r         rr   )r$   r5   r   rV   r   r:   rt   ru   )r   exc1exc2s      r   test_offsetWithMultiLineArgs!Test.test_offsetWithMultiLineArgsb  s    {{   OO &X 	 	a(2&a(2&r!   c                 &    U R                  S5        g )NzT
        def foo():
            '''
                >>> foo
            '''
        r^   rW   s    r   test_doctestCanReferToFunction#Test.test_doctestCanReferToFunctiont  s      	r!   c                 &    U R                  S5        g )Nz
        class Foo():
            '''
                >>> Foo
            '''
            def bar(self):
                '''
                    >>> Foo
                '''
        r^   rW   s    r   test_doctestCanReferToClass Test.test_doctestCanReferToClass|  ro   r!   c                     U R                  S[        R                  [        R                  5      R                  nUS   nU R	                  UR
                  S5        US   nU R	                  UR
                  S5        g )NaF  
            def buildurl(base, *args, **kwargs):
                """
                >>> buildurl('/blah.php', ('a', '&'), ('b', '=')
                '/blah.php?a=%26&b=%3D'
                >>> buildurl('/blah.php', a='&', 'b'='=')
                '/blah.php?b=%3D&a=%26'
                """
                pass
            r   r   r4   r   )r$   r5   r   r   r:   rt   r   s      r   !test_noOffsetSyntaxErrorInDoctest&Test.test_noOffsetSyntaxErrorInDoctest  so    [[	     " #+( 	 mQ'mQ'r!   c                 &    U R                  S5        g )Nz
        def func():
            """A docstring

            >>> func()
            1
            >>> _
            1
            """
            return 1
        r^   rW   s    r   test_singleUnderscoreInDoctest#Test.test_singleUnderscoreInDoctest  s     
 
	r!   c                 D    U R                  S[        R                  5        g )Nz
        from gettext import ugettext as _

        def doctest_stuff():
            '''
                >>> pass
            '''
        )r$   r5   UnusedImportrW   s    r   test_globalUnderscoreInDoctest#Test.test_globalUnderscoreInDoctest  s      ^^	r!   r)   N)r*   r+   r,   r-   r.   rH   rN   rR   rX   r[   r_   rb   re   r
   rj   rm   rx   r}   r   r   r   r   r   r   r   r   r   r/   r)   r!   r   r   r   0   s    K&/P)0V),V/*
 
&\% %

&
&%&B	&'$
(&r!   r   c                       \ rS rSrSrSrg)	TestOtheri  z2Run TestOther with each test wrapped in a doctest.r)   Nr*   r+   r,   r-   __doc__r/   r)   r!   r   r   r     s    <r!   r   c                       \ rS rSrSrSrg)TestImportsi  z4Run TestImports with each test wrapped in a doctest.r)   Nr   r)   r!   r   r   r     s    >r!   r   c                       \ rS rSrSrSrg)TestUndefinedNamesi  z;Run TestUndefinedNames with each test wrapped in a doctest.r)   Nr   r)   r!   r   r   r     s    Er!   r   )r   pyflakesr   r5   pyflakes.checkerr   r   r   r   pyflakes.test.test_otherr   r   pyflakes.test.test_importsr   "pyflakes.test.test_undefined_namesr   pyflakes.test.harnessr	   r
   r   r)   r!   r   <module>r      sl     "  7 : I 0C C@@8 @F=y =?- ?F(: Fr!   