��Qc@�s�dZddlmZddlZddlZddlmZddlmZye Wne
k
rrd�Z nXdejfd ��YZd
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
�Zd�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_warningstTruetsimplefiltertDeprecationWarningtassertEqualt
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 Rs ##
(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 Ri�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�Rtc(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.pyttest_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�scC�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�scC�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.pyttest_changed�s*
cC�sZxSdD]K}tjddd|�}|jt|�|d�|j|j|�qWdS(Ntxyz_RidRR(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\RidRR 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_childRRbRcR8tassertRaisest
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(
RRR7tinsert_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/(
RR7Rtappend_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�(RR7Rtnext_siblingRRc(RR9RBtp1((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_next_siblingYscC�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_siblingbscC�s|tjdg�}tjdg�}tjd||g�}|j|j|k�|j|jd�|j|jd�dS(Ni�(RR7Rtprev_siblingRRc(RR9RBRq((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_prev_siblingkscC�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__tsystversion_infoR R!R%R'R+R.R3R6R:R;R<R=RCRERFRLRNRQRSRVRXR[R]R`RdReRjRmRoRrRsRuRv(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyRsF
tTestPatternscB�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__RRzRRRtlib2to3RRt NameErrortTestCaseRR|(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt<module>
s
|