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

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


��Qc@�s�dZddlmZddlZddlZddlmZddlmZye	Wne
k
rrd�Z	nXdejfd	��YZd
ejfd��YZ
dS(sUnit tests for pytree.py.

NOTE: Please *don't* add doc strings to individual test methods!
In verbose mode, printing of the module, class and method name is much
more helpful than printing of (the first line of) the docstring,
especially when debugging a test.
i�(twith_statementNi(tsupport(tpytreecC�st|�}|j�|S(N(tlisttsort(tlsttl((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pytsorteds
t	TestNodescB�sIeZdZejd$kr'd�Znd�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�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%RS(%s(Unit tests for nodes (Base, Leaf, Node).iicC�s�tjdd�}tjdt��}tjdt�|j|j�d�|j	d�WdQX|j|j
d�|jt|�d�x$|D]}|j|j
tk�q�W|jt|dj�d	�|jt|d
j�d�dS(Nidtfootrecordtalwaystthiiis3get_prefix() is deprecated; use the prefix propertyis3set_prefix() is deprecated; use the prefix property(RtLeaftwarningstcatch_warningstTruetsimplefiltertDeprecationWarningtassertEqualt
get_prefixt
set_prefixtprefixtlent
assertTruetcategorytstrtmessage(tselfRtwtwarning((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_deprecated_prefix_methods$s
cC�sdS(N((R((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_instantiate_base3scC�s<tjdd�}|j|jd�|j|jd�dS(NidR	(RRRttypetvalue(Rtl1((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt	test_leaf8scC�s,tjdd�}|jt|�d�dS(NidR	sLeaf(100, 'foo')(RRRtrepr(RR$((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_repr=scC�s`tjdd�}|jt|�d�tjdddddf�}|jt|�d�dS(	NidR	tcontextt i
is foo(i
i(RRRR(RR$tl2((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt
test_leaf_strAscC�s5tjdd�}d|_|jt|�d�dS(Niitfoo_tfoo_5(RRRRR(RR$((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_str_numeric_valueGs	cC�s�tjdd�}tjddddd	f�}|j||�tjdd�}tjdd�}|j||�|j||�dS(
NidR	R(R)iiietbar(ii(RRRtassertNotEqual(RR$R*tl3tl4((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_equalityNscC�setjdd�}|j|jd�|j|j�d|_|j|jd�|j|j�dS(NidR	Rs  ##

(RRRRtassertFalsetwas_changedR(RR$((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_prefixWs	cC�sltjdd�}tjdd�}tjd||g�}|j|jd�|j|j||g�dS(NidR	i�R/i�(RRtNodeRR"tchildren(RR$R*tn1((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt	test_node_s
cC�sxtjdd�}tjddddd
f�}tjd||g�}|jt|�d	t|�t|�f�dS(NidR	R/R(R)iii�sNode(1000, [%s, %s])(ii(RRR7RR&(RR$R*R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_reprfs
cC�sbtjdd�}tjddddd
f�}tjd||g�}|jt|�d	�dS(NidR	R/R(R)iii�sfoo bar(ii(RRR7RR(RR$R*R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt
test_node_strmscC�s�tjdd�}|j|jd�tjd|g�}|j|jd�d|_|j|jd�|j|jd�dS(NidR	Ri�R)(RRRRR7(RR$R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_prefixss	cC�stjdddd�}tjdddd�}tjd||g�}|j|j�|j�|j|j�d�|j|j�d�tjdddd	�}tjd||g�}|j|j�|j�|j|j�d�|j|j�d�dS(
NidR	RtaR/tbi�Rtc(RRR7Rt
get_suffixR(RR$R*R9R1tn2((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_get_suffix|scC�sftjdd�}tjdgdddf�}|j||�tjdd	�}|j||�dS(
Ni�R(R)iii�((ii((RR7RR0(RR9RBtn3((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_equality�s
cC�s�tjdd�}tjdd�}tjd|g�}tjd|g�}|j||�tjdd�}tjd|g�}|j||�dS(NidR	i�R/(RRR7RR0(RR$R*R9RBR1RD((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_recursive_equality�scC�s�tjdd�}tjdd�}tjdd�}tjd|||g�}|j|j|||g�|jt|jt��|j|j	�tjdd�}|j
|�|j|j|||g�|jt|jt��|j|j	�dS(NidR	t+R/i�t-(RRR7RR8Rt
isinstanceRR4R5treplace(RR$R*R1R9tl2new((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_replace�s
cC�s�tjdd�}tjdd�}tjdd�}tjd|||g�}|jtjdd�tjdd�g�|jt|�d�|jt|jt	��dS(NidR	RGR/i�t*sfoo**bar(
RRR7RJRRRRIR8R(RR$R*R1R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_replace_with_list�s+cC�s�tjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}|jt|j��|||g�dS(NidR	R/tfooeyi�(RRR7RRtleaves(RR$R*R1RBRDR9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaves�scC�s�tjdd�}tjdd�}tjd||g�}tjdg�}tjd||g�}|j|j�d�|j|j�d�|j|j�d�dS(NidR	R/i�iii(RRR7Rtdepth(RR$R*RBRDR9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt
test_depth�scC�s�tjdd�}tjdd�}tjdd�}tjd||g�}tjd||g�}|jt|j��|||||g�dS(NidR	R/ROi�(RRR7RRt
post_order(RR$R*R1tc1R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_post_order�scC�s�tjdd�}tjdd�}tjdd�}tjd||g�}tjd||g�}|jt|j��|||||g�dS(NidR	R/ROi�(RRR7RRt	pre_order(RR$R*R1RUR9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_pre_order�scC�satjdd�}|j|j�|j�|j|j�tjdd�}tjd|g�}|j|j�|j�|j|j�tjdd�}tjdd�}tjdd�}tjd|||g�}tjd|g�}|j|j�|j|j�|j|j�|j�|j|j�|j|j�|j|j�dS(Nidtfi�R	RGR/(RRR4R5tchangedRR7(RR$R9R*R1RB((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_changed�s*


cC�sZxSdD]K}tjddd|�}|jt|�|d�|j|j|�qWdS(Ntxyz_RidRR(R\R(RRRRRR(RRR$((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_constructor_prefix�s
cC�s�x�d
D]�}tjdd�}tjdddd�}tjd||gd|�}|jt|�|d	�|j|j|�|j|j|�|j|jd�qWdS(NR\RidRR	Rt_i�tself_foo(sxyz_R(RRR7RRRR(RRR$R*R9((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_constructor_prefix�s
cC�sotjdd�}tjdd�}tjd||g�}tjd|g�}|j|j�d�|j|jg�|j|j|�|j|jd�|j|jd�|j|j	�|j
|j	�|j|j�d�|j|j�d�|j|jg�|j|jd�|j|jd�|j|jd�|j
|j	�|j
|j	�dS(NidR	i�ii(RRR7RtremoveR8tparenttNoneR4R5R(RR$R*R9RB((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_removes&cC�sbtjdg�}|j�|j|jd�tjdd�}|j�|j|jd�dS(Ni�idR	(RR7RaRRbRcR(RR9R$((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_remove_parentlesss

cC�s/tjdd�}tjd|g�}tjdd�}|jd|�|j|jd�|j|j|�|j|j|g�tjd|g�}|jd|�|j|jd�|j|j|�|j|jd�|j|j|g�|jt	|jd|�|jt
|jdt�dS(NidR	i�R/ii(RRR7t	set_childRRbRcR8tassertRaisest
IndexErrort	ExceptionR(RR$R9R*RB((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_set_child$scC�s�tjdd�}tjd|g�}tjdd�}|jd|�|j|j|�|j|j||g�tjdd�}|jd|�|j|j|||g�|jt|jdt	�dS(NidR	i�R/itabci(
RRR7tinsert_childRRbR8RgRiR(RR$R9R*R1((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_insert_child9scC�s�tjdg�}tjdd�}|j|�|j|j|�|j|j|g�tjdd�}|j|�|j|j|�|j|j||g�|jt|jt	�dS(Ni�idR	R/(
RR7Rtappend_childRRbR8RgRiR(RR9R$R*((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_append_childIs

cC�s|tjdg�}tjdg�}tjd||g�}|j|j|k�|j|jd�|j|jd�dS(Ni�(RR7Rtnext_siblingRRc(RR9RBtp1((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_next_siblingYscC�s|tjdd�}tjdd�}tjd||g�}|j|j|k�|j|jd�|j|jd�dS(NidR>R?i�(RRR7RRpRRc(RR$R*Rq((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_next_siblingbscC�s|tjdg�}tjdg�}tjd||g�}|j|j|k�|j|jd�|j|jd�dS(Ni�(RR7Rtprev_siblingRRc(RR9RBRq((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_prev_siblingkscC�s|tjdd�}tjdd�}tjd||g�}|j|j|k�|j|jd�|j|jd�dS(NidR>R?i�(RRR7RRtRRc(RR$R*Rq((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_leaf_prev_siblingts(ii(&t__name__t
__module__t__doc__tsystversion_infoR R!R%R'R+R.R3R6R:R;R<R=RCRERFRLRNRQRSRVRXR[R]R`RdReRjRmRoRrRsRuRv(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyRsF																
		
	
						
												tTestPatternscB�s2eZdZd�Zd�Zd�Zd�ZRS(s&Unit tests for tree matching patterns.c
C�s�tjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}tjdddd�}i}|j|j|d|��|j|i�|j|j|d|��|j|i�|j|j|d|��|j|i�|j|j|d|��|j|i|d6�i}|j|j|d|��|j|i�tjd|gdd�}	|j|	j|d|��|j|i�|j|	j|d|��|j|i�|j|	j|d|��|j|i|d6|d6�i}|j|	j|d|��|j|i�|j|	j|d|��|j|i�dS(	NidR	R/i�tnametpltresultstpn(	RRR7tLeafPatternR4tmatchRRtNodePattern(
RR$R*R1R9RBtrootR~trR�((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_basic_patterns�s>cC�sBtjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}tjdddd�}tjd|gdd�}tj|g||ggdd�}	i}
|j|	j|g|
��|j|
i�|j|	j|g|
��|j|
i�|j	|	j|g|
��|jt
|
j��dddg�|j|
d|�|j|
d|�|j|
d|g�|j|
i|d6|d6|gd6�i}
|j	|	j||g|
��|j|
i|d6||gd6�|j	|
d|k�i}
dS(	NidR	R/i�R}R~R�tpw(RRR7R�R�tWildcardPatternR4t	match_seqRRRtkeys(RR$R*R1R9RBR�R~R�R�R�((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt
test_wildcard�s2$%($cC�s�tjdd�}tjdd�}tjdd�}tjdd�}tjdd�}tjdd�}||||||g}tjd|�}tjddd	�}	tjddd
�}
tjddd�}tjddd�}tjddd
�}
tjddd�}tj|	|
|g||
g|	|
g||g|
|ggdddddd�}|jg|j|�D]}|d^q{dddddg�tjddd|gdd�}ttj|g|g��}|jt	|�d�|d\}}|j|d�|jt
|d�d�|j|d||||||g�x2dD]*}|j|d|tjd|��q`WdS(NiR>R?R@tdteRYi�tpatpbtpctpdtpetpftmintmaxiR}R�iiiiiR"tcontenttprtabcdeftp(RRR7R�R�Rtgenerate_matchesR�RRR(RtlatlbtlctldtletlfRPR�R�R�R�R�R�R�R�txR�tmatchesR@R�((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_generate_matches�s8!)!&
cC�s�tjdtjd�tjdd�tjd�f�}tjdd�}tjdd�}tjdd	�}tjd|||g�}i}|j|j||��|j|d|g�dS(
NiKiR}targsit(iR�t)(	RR�R�R�RR7RR�R(RtpatternR$R*R1tnodeR�((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_has_key_example�s	(RwRxRyR�R�R�R�(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyR|~s
	$		(Ryt
__future__RRzRRRtlib2to3RRt	NameErrortTestCaseRR|(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.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 [email protected].