Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/lib2to3/tests/test_util.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s{dZddlmZddlZddlmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZd	d
�Zdejfd��YZd
ejfd��YZdejfd��YZdefd��YZdefd��YZdefd��YZdejfd��YZdejfd��YZdejfd��YZdejfd��YZdS(s' Test suite for the code in fixer_util i(tsupporti�N(tNodetLeaf(t
fixer_util(tAttrtNametCalltComma(ttokenicCs@tj|�}x!t|�D]}|jd}qWd|_|S(Ni(Rtparse_stringtrangetchildrentNonetparent(tcodetstrip_levelsttreeti((s-/sys/lib/python2.7/lib2to3/tests/test_util.pytparses
	t
MacroTestCasecBseZd�ZRS(cCsGt|ttf�r-ttjj|�}n|jt|�|�dS(N(	t
isinstancettupletlistRRtsymstsimple_stmttassertEqualtstr(tselftnodetstring((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt	assertStrs(t__name__t
__module__R(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRst
Test_is_tuplecBs#eZd�Zd�Zd�ZRS(cCstjt|dd��S(NRi(Rtis_tupleR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR" scCsr|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��dS(Ns(a, b)s(a, (b, c))s((a, (b, c)),)s(a,)s()(t
assertTrueR"(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt
test_valid#s
cCs0|j|jd��|j|jd��dS(Ns(a)s('foo') % (b, c)(tassertFalseR"(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_invalid*s(RR R"R$R&(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR!s		tTest_is_listcBs#eZd�Zd�Zd�ZRS(cCstjt|dd��S(NRi(Rtis_listR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR(0scCsr|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��dS(Ns[]s[a]s[a, b]s[a, [b, c]]s[[a, [b, c]],](R#R((R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR$3s
cCs|j|jd��dS(Ns[]+[](R%R((R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR&:s(RR R(R$R&(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR'/s		t	Test_AttrcBseZd�Zd�ZRS(cCsZtddd�}|jttd�td��d�|jt|td��d�dS(Nsfoo()Ritatbsa.bsfoo().b(RRRR(Rtcall((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest?s%cCs5ttd�td��}|jt|�t�dS(NR*R+(RRRttypeR(Rtattr((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_returnsEs(RR R-R0(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR)>s	t	Test_NamecBseZd�ZRS(cCsL|jtd�d�|jtd�d�|jtddd�d�dS(NR*s
foo.foo().bartprefixR+tba(RR(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR-Ks(RR R-(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR1Jst	Test_CallcBs eZddd�Zd�ZRS(cCsfg}t|t�rPx+|D]#}|j|�|jt��qW|j�ntt|�||�S(sHelp the next test(RRtappendRtpopRR(RtnametargsR2Rtarg((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt_CallRs


c	Cs"dttjd�ttjd�ttjd�gttjd�ttjd�ttjd�ttjd�gttjd�ttjddd�gg}|j|jd	�d
�|j|jd|d�d�|j|jd|d�d
�|j|jd|ddd�d�dS(NiiiiR+tjR2t tAsA()sb(1,2,3)sa.b().csa.b().c(1,3,2,4)tds d(b, j)(RRRtNUMBERtSTRINGRR:(Rtkids((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR-\s!-  N(RR RR:R-(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyR4Qs
tTest_does_tree_importcBs,eZd�Zd�Zd�Zd�ZRS(cCsPtj||�}|r|Sx-|jD]"}|j||�}|r&|Sq&WdS(N(Rtfind_bindingRt_find_bind_rec(RR7Rtctchild((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRDkscCs1t|�}|jd|�}tj|||�S(Ntstart(RRDRtdoes_tree_import(RtpackageR7RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRHtsc	Csdddddf}xk|D]c\}}}|j|||d	|�}|j|�|j|||d	|�}|j|�qWdddddddf}xk|D]c\}}}|j|||d	|�}|j|�|j|||d	|�}|j|�q�WdS(NR*sfrom a import bsa.dsfrom a.d import bsd.asfrom d.a import bsimport bsimport b, c, ds
sfrom a import atxsfrom x import asfrom x import b, c, a, dsx.bsfrom x.b import asfrom x.b import b, c, a, dsimport asimport b, c, a, d(R*R*sfrom a import b(sa.dR*sfrom a.d import b(sd.aR*sfrom d.a import b(NR*simport b(NR*simport b, c, d(R*R*sfrom a import a(RJR*sfrom x import a(RJR*sfrom x import b, c, a, d(sx.bR*sfrom x.b import a(sx.bR*sfrom x.b import b, c, a, d(NR*simport a(NR*simport b, c, a, d(RRHR%R#(RRt
failing_testsRIR7timport_tnt
passing_tests((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttry_withzs,	
	
cCs|jd�dS(Nsdef foo():
	bar.baz()
	start=3(RO(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_in_function�s(RR RDRHRORP(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRBjs				tTest_find_bindingcBs�eZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCstj|t|�|�S(N(RRCR(RR7RRI((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRC�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*sa = bs
a = [b, c, d]s	a = foo()sa = foo().foo.foo[6][foo]sfoo = asfoo = (a, b, c)(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_assignment�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*s(a,) = bs(a, b, c) = [b, c, d]s(c, (d, a), b) = foo()s(a, b) = foo().foo[6][foo]s(foo, b) = (b, a)s(foo, (b, c)) = (a, b, c)(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_tuple_assignment�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*s[a] = bs[a, b, c] = [b, c, d]s[c, [d, a], b] = foo()s[a, b] = foo().foo[a][foo]s[foo, b] = (b, a)s[foo, [b, c]] = (a, b, c)(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_list_assignment�scCsh|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*s	foo.a = 5s
foo[a] = 5s
foo(a) = 5s
foo(a, b) = 5(R%RC(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_invalid_assignments�scCsh|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*simport asimport b, c, a, dsimport bsimport b, c, d(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_import�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd	��dS(
NR*sfrom x import asfrom a import asfrom x import b, c, a, dsfrom x.b import asfrom x.b import b, c, a, dsfrom a import bsfrom a.d import bsfrom d.a import b(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import�scCsh|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(NR*s
import b as asimport b as a, c, a as f, ds
import a as fsimport b, c as f, d as e(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_import_as�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(	NR*sfrom x import b as asfrom x import g as a, d as bsfrom x.b import t as asfrom x.b import g as a, dsfrom a import b as tsfrom a.d import b as tsfrom d.a import b as t(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import_as�scCsn|j|jdd��|j|jdd��|j|jddd��|j|jddd��dS(NR+simport bsimport b, c, dRE(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_import_with_package�scCs8|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jdd	d��|j|jdd
d��|j|jddd��|j|jddd
��|j|jddd
��|j|jddd��dS(NR*sfrom x import aRJsfrom a import asfrom x import *sfrom x import b, c, a, dsfrom x.b import asx.bsfrom x.b import *sfrom x.b import b, c, a, dsfrom a import bsfrom a.d import bsa.dsfrom d.a import bsfrom x.y import *sa.b(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import_with_package�scCsX|j|jddd��|j|jddd��|j|jddd��dS(NR*simport b.c as asb.cs
import a as ftf(R%RC(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_import_as_with_package�scCs�|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd	��|j|jddd
��dS(NR*sfrom x import b as aRJsfrom x import g as a, d as bsfrom x.b import t as asx.bsfrom x.b import g as a, dsfrom a import b as tR+tt(R%RC(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt test_from_import_as_with_package�scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��d	}|j|jd|��dS(
NR*s
def a(): passsdef a(b, c, d): passsdef a(): b = 7sdef d(b, (c, a), e): passsdef d(a=7): passsdef d(a): passsdef d(): a = 7sG
            def d():
                def a():
                    pass(R#RCR%(Rts((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_function_def�scCs|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd	��|j|jdd
��|j|jdd��d}|j|jd|��dS(
NR*s
class a: passsclass a(): passsclass a(b): passsclass a(b, c=8): passs
class d: passsclass d(a): passsclass d(b, a=7): passsclass d(b, *a): passsclass d(b, **a): passsclass d: a = 7sK
            class d():
                class a():
                    pass(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_class_def
scCs�|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��dS(	NR*sfor a in r: passsfor a, b in r: passsfor (a, b) in r: passsfor c, (a,) in r: passsfor c, (a, b) in r: passsfor c in r: a = csfor c in a: pass(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_forscCs�d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d	}|j|jd|��dS(
NsM
            for b in r:
                for a in b:
                    passR*sP
            for b in r:
                for a, c in b:
                    passsR
            for b in r:
                for (a, c) in b:
                    passsP
            for b in r:
                for (a,) in b:
                    passsU
            for b in r:
                for c, (a, d) in b:
                    passsN
            for b in r:
                for c in b:
                    a = 7sN
            for b in r:
                for c in b:
                    d = asN
            for b in r:
                for c in a:
                    d = 7(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_for_nested%s cCs6|j|jdd��|j|jdd��dS(NR*sif b in r: a = csif a in r: d = e(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_ifVscCsBd}|j|jd|��d}|j|jd|��dS(NsL
            if b in r:
                if c in d:
                    a = cR*sL
            if b in r:
                if c in d:
                    c = a(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_if_nestedZscCs6|j|jdd��|j|jdd��dS(NR*swhile b in r: a = cswhile a in r: d = e(R#RCR%(R((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt
test_whilegscCsBd}|j|jd|��d}|j|jd|��dS(NsR
            while b in r:
                while c in d:
                    a = cR*sR
            while b in r:
                while c in d:
                    c = a(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_while_nestedkscCs�d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��dS(NsQ
            try:
                a = 6
            except:
                b = 8R*sQ
            try:
                b = 8
            except:
                a = 6s�
            try:
                b = 8
            except KeyError:
                pass
            except:
                a = 6sQ
            try:
                b = 8
            except:
                b = 6(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_try_exceptxscCs�d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��dS(	Ns�
            try:
                try:
                    a = 6
                except:
                    pass
            except:
                b = 8R*s�
            try:
                b = 8
            except:
                try:
                    a = 6
                except:
                    passs�
            try:
                b = 8
            except:
                try:
                    pass
                except:
                    a = 6s�
            try:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6
            except:
                passs�
            try:
                pass
            except:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6sQ
            try:
                b = 8
            except:
                b = 6s
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = y(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_nested�s		cCs�d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��dS(Ns|
            try:
                c = 6
            except:
                b = 8
            finally:
                a = 9R*sR
            try:
                b = 8
            finally:
                a = 6sR
            try:
                b = 8
            finally:
                b = 6s|
            try:
                b = 8
            except:
                b = 9
            finally:
                b = 6(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_finally�scCsad}|j|jd|��d}|j|jd|��d}|j|jd|��dS(Ns�
            try:
                c = 6
            except:
                b = 8
            finally:
                try:
                    a = 9
                except:
                    b = 9
                finally:
                    c = 9R*s�
            try:
                b = 8
            finally:
                try:
                    pass
                finally:
                    a = 6s�
            try:
                b = 8
            finally:
                try:
                    b = 6
                finally:
                    b = 7(R#RCR%(RR`((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_finally_nesteds		N(RR RRCRRRSRTRURVRWRXRYRZR[R]R_RaRbRcRdReRfRgRhRiRjRkRl(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRQ�s2						
					
							1		
		
		M	!tTest_touch_importcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs9td�}tjdd|�|jt|�d�dS(Ns"""foo"""
bar()tfoos"""foo"""
import foo
bar()

(RRttouch_importRRR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_after_docstring*scCs9td�}tjdd|�|jt|�d�dS(Ns"""foo"""
import bar
bar()Rns'"""foo"""
import bar
import foo
bar()

(RRRoRRR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_after_imports/scCs9td�}tjdd|�|jt|�d�dS(Nsbar()Rnsimport foo
bar()

(RRRoRRR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_beginning4scCs9td�}tjdd|�|jt|�d�dS(Nsbar()thtmltescapesfrom html import escape
bar()

(RRRoRR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRW9scCs9td�}tjdd|�|jt|�d�dS(Nsbar()tcgisimport cgi
bar()

(RRRoRRR(RR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_name_import>s(RR RpRqRrRWRv(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRm(s
				tTest_find_indentationcBseZd�Zd�ZRS(cCsQtj}td�}|j||�d�td�}|j||�d�dS(Nsnode()ut(Rtfind_indentationRR(RtfiR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_nothingEs
	cCs�tj}td�}|j||�d�|j||jdjdjd�d�td�}|j||jdjdjd�d�dS(Nsdef f():
    x()uiiiu    sdef f():
    x()
    y()(RRyRRR(RRzR((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyttest_simpleLs	+(RR R{R|(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyRwCs	(t__doc__RxRtos.pathtostlib2to3.pytreeRRtlib2to3Rtlib2to3.fixer_utilRRRRt
lib2to3.pgen2RRtTestCaseRR!R'R)R1R4RBRQRmRw(((s-/sys/lib/python2.7/lib2to3/tests/test_util.pyt<module>s$"	,�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.