+
    Dfj=*                     l    ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	  ! R R]P                  4      tR# )	    )unittest)xpath)Element)
XPathQuery)SyntaxErrorc                     a  ] tR t^t o V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltV 3R! lR" ltV 3R# lR$ ltV 3R% lR& ltV 3R' lR( ltV 3R) lR* ltV 3R+ lR, ltV 3R- lR. ltV 3R/ lR0 ltV 3R1 lR2 ltV 3R3 lR4 ltV 3R5 lR6 ltR7tV t R8# )9
XPathTestsc                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "?/usr/lib/python3/dist-packages/twisted/words/test/test_xpath.py__annotate__XPathTests.__annotate__   s     =, =,t =,    c                   \        R4      V n        RV P                  R&   RV P                  R&   V P                  P                  R4       V P                  P                  R4      V n        V P                  P                  R4      V n        V P
                  P                  R4      V n        V P                  P                  R	4       V P                  P                  R
4       V P                  P                  R4      V n        RV P                  R&   V P                  P                  R4      V n        V P                  P                  R4      V n	        V P                  P                  R4      V n
        V P                  P                  R4       V P                  P                  R4      V n        V P                  P                  R4      V n        RV P                  R&   RV P                  R&   V P                  P                  R4      V n        V P                  P                  R4      V n        V P                  P                  R4       V P                  P                  R4      V n        RV P                  R&   RV P                  R&   V P                  P                  R4      V n        V P                  P                  R4      V n        V P"                  P                  R4       V P                  P                  R4      V n        RV P$                  R&   RV P$                  R&   RV P$                  R&   V P$                  P                  R4      V n        V P&                  P                  R4       R# )testnsfoovalue1attrib1zuser@host/resourceattrib3somecontentbargarDEFsomemorecontentvalue2attrib2ABCvalue4attrib4value5attrib5JKLMNOvalue6   áattrib6quuxu   ☃N)r   r   )r   e
addContent
addElementbar1subfoogar1bar2bar3subfoo2gar2bar4bar5subfoo3gar3bar6subfoo4gar4bar7r,   selfs   &r   setUpXPathTests.setUp   s|   8 *+$y0y-(FF%%e,	ii**51KK**51			U#+,FF%%e,	'		)II((/	yy++E2II((/			U#FF%%e,	FF%%e,	'		)'		)yy++E2II((/			U#FF%%e,	'		)'		)yy++E2II((/			U#FF%%e,	'		)'		)#		)II((0			]+r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   L   s     
 
D 
r   c           	        V P                  \        P                  ! RV P                  4      R4       V P                  \        P                  ! RV P                  4      V P
                  V P                  V P                  V P                  V P                  V P                  .4       V P                  \        P                  ! RV P                  4      R4       V P                  \        P                  ! RV P                  4      RR.4       R# )z-
Test basic operation of the static methods.
/foo/barT/foor   r   N)assertEqualr   matchesr-   queryForNodesr0   r3   r7   r8   r;   r>   queryForStringqueryForStringListr?   s   &r   test_staticMethodsXPathTests.test_staticMethodsL   s     	z466:DA
DFF3YY		499diiDIIN	
 	--fdff=}M$$VTVV4}FW6X	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   Z        0 0T 0r   c                r    \        R4      pV P                  VP                  V P                  4      ^4       R# )z#
Test matching foo with child bar.
rE   Nr   rG   rH   r-   r@   xps   & r   test_locationFooBarXPathTests.test_locationFooBarZ   s+     
#DFF+Q/r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   a   s     
 
 
r   c                
   \        R4      pV P                  VP                  V P                  4      ^4       V P                  VP	                  V P                  4      V P
                  V P                  V P                  .4       R# )z(
Test finding foos at the second level.
z/foo/bar/fooN)r   rG   rH   r-   rI   r1   r9   r<   rR   s   & r   test_locationFooBarFoo!XPathTests.test_locationFooBarFooa   s`     'DFF+Q/TVV$t{{DLL$,,&O	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   k   rO   r   c                r    \        R4      pV P                  VP                  V P                  4      ^ 4       R# )z
Test not finding bar3.
z	/foo/bar3NrQ   rR   s   & r   test_locationNoBar3XPathTests.test_locationNoBar3k   s+     $DFF+Q/r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   r   s     	
 	
 	
r   c           	     L   \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  V P                  V P                  V P                  V P                  .4       R# )z
Test finding childs of foo.
z/foo/*TN)r   rG   rH   r-   rI   r0   r3   r7   r8   r;   r>   rR   s   & r   test_locationAllChilds!XPathTests.test_locationAllChildsr   ss     !DFF+T2TVV$YY		499diiDIIN	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   }   s     3 3 3r   c                r    \        R4      pV P                  VP                  V P                  4      R4       R# )z#
Test matching foo with attribute.
z/foo[@attrib1]TNrQ   rR   s   & r   test_attributeXPathTests.test_attribute}   s,     ()DFF+T2r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     @ @D @r   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  .4       R# )z.
Test find nodes with attribute having value.
z/foo/*[@attrib2='value2']TN)r   rG   rH   r-   rI   r3   rR   s   & r   test_attributeWithValueAny%XPathTests.test_attributeWithValueAny   Q     34DFF+T2))$&&1DII;?r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     @ @t @r   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  .4       R# )z9
Nodes' attributes can be matched with non-ASCII values.
u   /foo/*[@attrib6='á']TN)r   rG   rH   r-   rI   r>   rR   s   & r   test_locationWithValueUnicode(XPathTests.test_locationWithValueUnicode   sQ     /0DFF+T2))$&&1DII;?r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      rO   r   c                r    \        R4      pV P                  VP                  V P                  4      ^4       R# )z$
Test matching node with namespace.
z/foo[@xmlns='testns']/barNrQ   rR   s   & r   test_namespaceFoundXPathTests.test_namespaceFound   ,     34DFF+Q/r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     0 0 0r   c                r    \        R4      pV P                  VP                  V P                  4      ^ 4       R# )z.
Test not matching node with wrong namespace.
z/foo[@xmlns='badns']/bar2NrQ   rR   s   & r   test_namespaceNotFound!XPathTests.test_namespaceNotFound   rs   r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     0 0 0r   c                r    \        R4      pV P                  VP                  V P                  4      ^4       R# )z1
Test matching node with attribute having value.
z/foo[@attrib1='value1']NrQ   rR   s   & r   test_attributeWithValue"XPathTests.test_attributeWithValue   s,     12DFF+Q/r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     C CT Cr   c                r    \        R4      pV P                  VP                  V P                  4      R4       R# )z=
queryforString on absolute paths returns their first CDATA.
rF   r   N)r   rG   rJ   r-   rR   s   & r   test_queryForStringXPathTests.test_queryForString   s-     **4662MBr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     
 
 
r   c                v    \        R4      pV P                  VP                  V P                  4      RR.4       R# )z?
queryforStringList on absolute paths returns all their CDATA.
rF   r   r   Nr   rG   rK   r-   rR   s   & r   test_queryForStringList"XPathTests.test_queryForStringList   s6     !!$&&)M;L+M	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     
 
D 
r   c                v    \        R4      pV P                  VP                  V P                  4      RR.4       R# )z?
queryforStringList on relative paths returns all their CDATA.
z//foor   r   Nr   rR   s   & r   "test_queryForStringListAnyLocation-XPathTests.test_queryForStringListAnyLocation   s6      !!$&&)M;L+M	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     
 
D 
r   c           	         \        R4      pV P                  VP                  V P                  4      V P                  V P
                  V P                  V P                  V P                  V P                  .4       R# )z
Test finding nodes.
rE   N)
r   rG   rI   r-   r0   r3   r7   r8   r;   r>   rR   s   & r   test_queryForNodesXPathTests.test_queryForNodes   sV     
#TVV$YY		499diiDIIN	
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     3 3D 3r   c                r    \        R4      pV P                  VP                  V P                  4      R4       R# )z'
Test matching a node with given text.
z/foo[text() = 'somecontent']TNrQ   rR   s   & r   test_textConditionXPathTests.test_textCondition   s,     67DFF+T2r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     @ @4 @r   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  .4       R# )z;
A node can be matched by text with non-ascii code points.
u   //*[text()='☃']TN)r   rG   rH   r-   rI   r,   rR   s   & r   test_textConditionUnicode$XPathTests.test_textConditionUnicode   rj   r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     3 3d 3r   c                r    \        R4      pV P                  VP                  V P                  4      R4       R# )z
Test for not operator.
z/foo[not(@nosuchattrib)]TNrQ   rR   s   & r   test_textNotOperatorXPathTests.test_textNotOperator   s,     23DFF+T2r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     	V 	V 	Vr   c                z   \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  V P                  V P                  .4       V P                  VP                  V P                  4      . RO4       R# )zC
Test finding any nodes named gar and getting their text contents.
z//garTN)r   r"   r'   r(   )
r   rG   rH   r-   rI   r2   r6   r:   r=   rK   rR   s   & r   test_anyLocationAndText"XPathTests.test_anyLocationAndText   s      DFF+T2TVV$tyy$))TYY		&R	
 	..tvv68TUr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     
 
$ 
r   c           
     b   \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  V P                  V P                  V P                  V P                  V P                  .4       R# )z#
Test finding any nodes named bar.
//barTN)r   rG   rH   r-   rI   r0   r3   r4   r7   r8   r;   r>   rR   s   & r   test_anyLocationXPathTests.test_anyLocation   s      DFF+T2TVV$															
r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     H H Hr   c                ^    \        R4      pV P                  \        VP                  R4       R# )zV
L{XPathQuery.queryForString} should raise a L{NotImplementedError}
for any location.
r   N)r   assertRaisesNotImplementedErrorrJ   rR   s   & r   test_anyLocationQueryForString)XPathTests.test_anyLocationQueryForString   s'    
  -r/@/@$Gr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r     s     @ @$ @r   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  .4       R# )z)
Test boolean and operator in condition.
z.//bar[@attrib4='value4' and @attrib5='value5']TN)r   rG   rH   r-   rI   r8   rR   s   & r   test_andOperatorXPathTests.test_andOperator  sQ     HIDFF+T2))$&&1DII;?r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r     s     K K Kr   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  .4       R# )z(
Test boolean or operator in condition.
z-//bar[@attrib5='value4' or @attrib5='value5']TN)r   rG   rH   r-   rI   r8   r;   rR   s   & r   test_orOperatorXPathTests.test_orOperator  sX     GHDFF+T2))$&&1DIItyy3IJr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r     s     	K 	KT 	Kr   c                    \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  .4       R# )z;
Test multiple boolean operators in condition with parens.
zf//bar[@attrib4='value4' and
                                 (@attrib5='value4' or @attrib5='value6')]TN)r   rG   rH   r-   rI   r;   r>   rR   s   & r   test_booleanOperatorsParens&XPathTests.test_booleanOperatorsParens  s_     N
 	DFF+T2))$&&1DIItyy3IJr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   #  s     
V 
Vt 
Vr   c                
   \        R4      pV P                  VP                  V P                  4      R4       V P                  VP	                  V P                  4      V P
                  V P                  V P                  .4       R# )z>
Test multiple boolean operators in condition without parens.
z//bar[@attrib5='value4' or
                                 @attrib5='value5' or
                                 @attrib5='value6']TN)r   rG   rH   r-   rI   r8   r;   r>   rR   s   & r   test_booleanOperatorsNoParens(XPathTests.test_booleanOperatorsNoParens#  sd     7

 	DFF+T2))$&&1DIItyy$))3TUr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   /  s     
 
t 
r   c                    V P                  \        \        R4      pV P                  VP                  P                  R4      RVP                  ,          4       R# )ze
A missing closing bracket raises a SyntaxError.

This test excercises the most common failure mode.
z//bar[@attrib1zTrying to find one ofzCSyntaxError message '%s' doesn't start with 'Trying to find one of'N)r   r   r   
assertTruemsg
startswith)r@   excs   & r   test_badXPathNoClosingBracket(XPathTests.test_badXPathNoClosingBracket/  sG     Z9MNGG67Ugg	
r   )r0   r3   r4   r7   r8   r;   r>   r-   r2   r6   r:   r=   r,   r1   r5   r9   r<   N)!__name__
__module____qualname____firstlineno__rA   rL   rT   rX   r\   r`   rd   rh   rm   rq   rv   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell__)r   s   @r   r	   r	      s(    =, =,~
 
0 0
 
0 0	
 	
3 3@ @@ @0 00 00 0C C
 

 

 
3 3@ @3 3	V 	V
 
&H H@ @K K	K 	K
V 
V
 
r   r	   N)twisted.trialr   twisted.words.xishr   twisted.words.xish.domishr   twisted.words.xish.xpathr   twisted.words.xish.xpathparserr   TestCaser	   r   r   r   <module>r      s*   
 # $ - / 6n
"" n
r   