bg82ddlZddlZddlmZddlmZmZmZm Z ddl m Z ddl m Zddlm ZddlmZmZGddZGdd eZ Gd d ee Z Gd d eeZGddeeZdS)N)messages)PYPY DoctestScope FunctionScope ModuleScope)Test)TestCaseskipc(eZdZdZdZfdZxZS) _DoctestMixinTcXg}tj|D]}|dkrn|ds|dsq|ds\|dsG|ds2|ds|r!|dd rd |z}nd |z}||tjd }|d |zS)N zexcept:zexcept zfinally:zelse:zelif )z>>> @z... @z... %sz>>> %szo def doctest_something(): """ %s """ z )textwrapdedent splitlinesstrip startswithappendjoin)selfinputlineslinedoctestificators l/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyflakes/test/test_doctests.py doctestifyz_DoctestMixin.doctestifysCOE**5577  Dzz||r!!//#&& '//),, '//),, '//*-- '//'** ' //'** '  ' #2Y112DEE ' $$ LL    "/+ !1!1%!8!888cdtj||g|Ri|S)N)superflakesr)rrargskw __class__s rr"z_DoctestMixin.flakes-s5uww~dooe44BtBBBrBBBr)__name__ __module__ __qualname__ withDoctestrr" __classcell__)r%s@rr r sUK9990CCCCCCCCCrr ceZdZdZdZdZdZdZdZdZ dZ d Z e d d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdS)rTc |d}|j}d|D}d|D}d|D}|t|d|t|d|d}|d}||t ||t ||t||t | d|| d|| d ||t|d| d |dd S) z-Check that a doctest is given a DoctestScope.z m = None def doctest_stuff(): ''' >>> d = doctest_stuff() ''' f = m return f c.g|]}|jtu|Sr%r.0scopes r z)Test.test_scope_class..C.IIIK)G)GE)G)G)Grc.g|]}|jtu|Sr.r%rr0s rr3z)Test.test_scope_class..E.JJJL)H)HE)H)H)Hrc.g|]}|jtu|Sr.r%rr0s rr3z)Test.test_scope_class..G.KKKM)I)IE)I)I)Irrm doctest_stuffdfN) r" deadScopes assertEquallenassertIsInstancerrassertNotIsInstancerassertInrcheckerscopes module_scopesdoctest_scopesfunction_scopes module_scope doctest_scopes rtest_scope_classzTest.test_scope_class5s++    #II%III JJ%JJJKK%KKK ]++Q/// ^,,a000$Q' &q)  m\::: m[999    >>>   |<<< c<((( o|444 c=))) _--q111 c?1-.....rcl|d}|j}d|D}d|D}d|D}|t|d|t|d|d}|d}|d||d||d ||t|d |d |d|d |dd S)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 c.g|]}|jtu|Sr.r/r0s rr3z4Test.test_nested_doctest_ignored..rr4rc.g|]}|jtu|Sr.r6r0s rr3z4Test.test_nested_doctest_ignored..tr7rc.g|]}|jtu|Sr.r9r0s rr3z4Test.test_nested_doctest_ignored..vr:rr;rr<r=function_in_doctestr?dfN)r"r@rArBrErFs rtest_nested_doctest_ignoredz Test.test_nested_doctest_ignored]sr++   $#II%III JJ%JJJKK%KKK ]++Q/// ^,,a000$Q' &q)  c<((( o|444 +];;; _--q111 c?1-... dOA./////rc|d}|j}d|D}d|D}d|D}|t|d|t|d|d}|d}|d||d||t|d |d |d|d |d|d |d|d |d S)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 c.g|]}|jtu|Sr.r/r0s rr3z;Test.test_global_module_scope_pollution..r4rc.g|]}|jtu|Sr.r6r0s rr3z;Test.test_global_module_scope_pollution..r7rc.g|]}|jtu|Sr.r9r0s rr3z;Test.test_global_module_scope_pollution..r:rr;rr=rSrTr?rUr<N)r"r@rArBrE assertNotInrFs r"test_global_module_scope_pollutionz'Test.test_global_module_scope_pollutions++    #II%III JJ%JJJKK%KKK ]++Q/// ^,,a000$Q' &q)  o|444 +];;; _--q111 c?1-... dOA./// c?1-... l+++++rcF|dtjdS)Nzn global m def doctest_stuff(): ''' >>> m ''' r"r< UndefinedNamers rtest_global_undefinedzTest.test_global_undefineds.  _     rc\|dtjtjdS)z*Doctest within nested class are processed.a class C: class D: ''' >>> m ''' def doctest_stuff(self): ''' >>> m ''' return 1 Nr^r`s rtest_nested_classzTest.test_nested_classs2  _ao / / / / /rc0|ddS)z>> syntax error >>> inner_function() 1 >>> m ''' return 1 m = inner_function() return m Nr"r`s rtest_ignore_nested_functionz Test.test_ignore_nested_functions)  rcF|dtjdS)z#Doctest may not access class scope.z class C: def doctest_stuff(self): ''' >>> m ''' return 1 m = 1 Nr^r`s rtest_inaccessible_scope_classz"Test.test_inaccessible_scope_classs.  _     rc0|ddS)Nzr import foo def doctest_stuff(): ''' >>> foo ''' rer`s rtest_importBeforeDoctestzTest.test_importBeforeDoctests'       rtodocF|dtjdS)Nz import foo def doctest_stuff(): """ >>> import foo >>> foo """ foo )r"r<RedefinedWhileUnusedr`s rtest_importBeforeAndInDoctestz"Test.test_importBeforeAndInDoctests/   # % % % % %rc0|ddS)Nz def doctest_stuff(): """ >>> import foo >>> foo """ import foo foo() rer`s rtest_importInDoctestAndAfterz!Test.test_importInDoctestAndAfter'  rc|dtjjd}||jd||jddS)Nzg def doctest_stuff(): """ >>> x # line 5 """ r r"r<r_rrAlinenocolrexcs rtest_offsetInDoctestszTest.test_offsetInDoctestsekk _'q* Q''' "%%%%%rc|dtjjd}||jd||jddS)Nzo def doctest_stuff(): """ >>> lambda: x # line 5 """ rrsrurxs rtest_offsetInLambdasInDoctestsz#Test.test_offsetInLambdasInDoctestsr{rc|dtjjd}||jd||jddS)Nzm def doctest_stuff(): """ >>> x = 5 """ x rrurxs rtest_offsetAfterDoctestszTest.test_offsetAfterDoctests)sekk  _  'q * Q''' !$$$$$rc|dtjtjtjj}|d}||jdt s,tjdkr||j dn||j d|d}||jdt r||j d n||j d |d }||jd t stjdkr||j d dS||j ddS) Nz def doctest_stuff(): """ >>> from # line 4 >>> fortytwo = 42 >>> except Exception: """ rrr;rs rT r"r<DoctestSyntaxErrorrrArvrsys version_inforwr exceptionsrys rtest_syntaxErrorInDoctestzTest.test_syntaxErrorInDoctest7sq[[    " "#+ m Q''' *(F22   SWb ) ) ) )   SWb ) ) ) m Q'''  *   SWb ) ) ) )   SWb ) ) )m Q'''  *3#v--   SWb ) ) ) ) )   SWb ) ) ) ) )rc0|dtjjd}||jdt stjdkr||j ddS||j ddS)Nz| def doctest_stuff(): """ >>> if True: ... pass """ rrsrrrrrxs rtest_indentationErrorInDoctestz#Test.test_indentationErrorInDoctest[skk  ! ## $,A / Q'''  *3#v--   SWb ) ) ) ) )   SWb ) ) ) ) )rcD|dtjtjj\}}||jd||jd||jd||jddS)Nz def doctest_stuff(arg1, arg2, arg3): """ >>> assert >>> this """ rrt)r"r<rr_rrArvrw)rexc1exc2s rtest_offsetWithMultiLineArgsz!Test.test_offsetWithMultiLineArgsis{{   O  & t a((( 2&&& a((( 2&&&&&rc0|ddS)NzT def foo(): ''' >>> foo ''' rer`s rtest_doctestCanReferToFunctionz#Test.test_doctestCanReferToFunction{s'       rc0|ddS)Nz class Foo(): ''' >>> Foo ''' def bar(self): ''' >>> Foo ''' rer`s rtest_doctestCanReferToClassz Test.test_doctestCanReferToClassrqrc|dtjtjj}|d}||jd|d}||jddS)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 rrr;r)r"r<rrrArvrs r!test_noOffsetSyntaxErrorInDoctestz&Test.test_noOffsetSyntaxErrorInDoctestsz[[    " "#+ m Q'''m Q'''''rc0|ddS)Nz def func(): """A docstring >>> func() 1 >>> _ 1 """ return 1 rer`s rtest_singleUnderscoreInDoctestz#Test.test_singleUnderscoreInDoctests'  rcF|dtjdS)Nz from gettext import ugettext as _ def doctest_stuff(): ''' >>> pass ''' )r"r< UnusedImportr`s rtest_globalUnderscoreInDoctestz#Test.test_globalUnderscoreInDoctests.  ^     rN)r&r'r(r)rNrVr\rarcrfrhrjr rnrprzr~rrrrrrrrrr.rrrr1slK&/&/&/P)0)0)0V),),),V / / /   *       T&\\ % %\ %     & & & & & & % % %"*"*"*H * * *'''$       (((&    rrceZdZdZdS) TestOtherz2Run TestOther with each test wrapped in a doctest.Nr&r'r(__doc__r.rrrrs<<<>>>rrceZdZdZdS)TestUndefinedNamesz;Run TestUndefinedNames with each test wrapped in a doctest.Nrr.rrrrsEEEErr)rrpyflakesrr<pyflakes.checkerrrrrpyflakes.test.test_otherrrpyflakes.test.test_importsr"pyflakes.test.test_undefined_namesrpyflakes.test.harnessr r r r.rrrs """""" 766666::::::IIIIII00000000CCCCCCCC@FFFFF8FFFR ===== y===?????-???FFFFF(:FFFFFr