��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�s|jttj�dS(N(tassertRaisestAssertionErrorRtBase(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�R2i�(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 R2R+R,iii�sNode(1000, [%s, %s])(ii(RRR:RR)(RR'R-R<((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_node_reprfs
cC�sbtjdd�}tjddddd
f�}tjd||g�}|jt|�d �dS(NidR R2R+R,iii�sfoo bar(ii(RRR:RR(RR'R-R<((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,(RRRRR:(RR'R<((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 RtaR2tbi�Rtc(RRR:Rt
get_suffixR(RR'R-R<R4tn2((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_get_suffix|scC�sftjdd�}tjdgdddf�}|j||�tjdd �}|j||�dS(
Ni�R+R,iii�((ii((RR:RR3(RR<REtn3((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�R2(RRR:RR3(RR'R-R<RER4RG((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+R2i�t-(RRR:RR;Rt
isinstanceRR7R8treplace(RR'R-R4R<tl2new((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 RJR2i�t*sfoo**bar(
RRR:RMRRRRLR;R(RR'R-R4R<((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 R2tfooeyi�(RRR:RRtleaves(RR'R-R4RERGR<((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 R2i�iii(RRR:Rtdepth(RR'R-RERGR<((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 R2RRi�(RRR:RRt
post_order(RR'R-R4tc1R<((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 R2RRi�(RRR:RRt pre_order(RR'R-R4RXR<((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 RJR2(RRR7R8tchangedRR:(RR'R<R-R4RE((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(RRR:RRRR(RRR'R-R<((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(RRR:RtremoveR;tparenttNoneR7R8R(RR'R-R<RE((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_removes&cC�sbtjdg�}|j�|j|jd�tjdd�}|j�|j|jd�dS(Ni�idR (RR:RdRReRfR(RR<R'((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�R2ii(RRR:t set_childRReRfR;R!t
IndexErrort ExceptionR(RR'R<R-RE((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�R2itabci(
RRR:tinsert_childRReR;R!RkR(RR'R<R-R4((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 R2(
RR:Rtappend_childRReR;R!RkR(RR<R'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�(RR:Rtnext_siblingRRf(RR<REtp1((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(NidRARBi�(RRR:RRrRRf(RR'R-Rs((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�(RR:Rtprev_siblingRRf(RR<RERs((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(NidRARBi�(RRR:RRvRRf(RR'R-Rs((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.R1R6R9R=R>R?R@RFRHRIRORQRTRVRYR[R^R`RcRgRhRlRoRqRtRuRwRx(((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 R2i�tnametpltresultstpn( RRR:tLeafPatternR7tmatchRRtNodePattern(
RR'R-R4R<REtrootR�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 R2i�RR�R�tpw(RRR:R�R�tWildcardPatternR7t match_seqRRRtkeys(RR'R-R4R<RER�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(NiRARBRCtdteR\i�tpatpbtpctpdtpetpftmintmaxiRR�iiiiiR%tcontenttprtabcdeftp(RRR:R�R�Rtgenerate_matchesR�RRR(RtlatlbtlctldtletlfRSR�R�R�R�R�R�R�R�txR�tmatchesRCR�((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(
NiKiRtargsit(iR�t)( RR�R�R�RR:RR�R(RtpatternR'R-R4tnodeR�((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyttest_has_key_example�s (RyRzR{R�R�R�R�(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyR~~s
$ (R{t
__future__RR|RRRtlib2to3RRt NameErrortTestCaseRR~(((s//sys/lib/python2.7/lib2to3/tests/test_pytree.pyt<module>
s
|