§
    Étºf=*  ã                   óh   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d„ dej
        ¦  «        ZdS )	é    )Úunittest)Úxpath)ÚElement)Ú
XPathQuery)ÚSyntaxErrorc                   óæ   — e Zd Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )Ú
XPathTestsÚreturnNc                 óB  — t          d¦  «        | _        d| j        d<   d| j        d<   | j                             d¦  «         | j                             d¦  «        | _        | j                             d¦  «        | _        | j                             d	¦  «        | _        | j                             d
¦  «         | j                             d¦  «         | j                             d¦  «        | _        d| j        d<   | j                             d¦  «        | _        | j                             d¦  «        | _	        | j                             d	¦  «        | _
        | j
                             d¦  «         | j                             d¦  «        | _        | j                             d¦  «        | _        d| j        d<   d| j        d<   | j                             d¦  «        | _        | j                             d	¦  «        | _        | j                             d¦  «         | j                             d¦  «        | _        d| j        d<   d| j        d<   | j                             d¦  «        | _        | j                             d	¦  «        | _        | j                             d¦  «         | j                             d¦  «        | _        d| j        d<   d| j        d<   d| j        d<   | j                             d¦  «        | _        | j                             d¦  «         d S )N)ÚtestnsÚfooÚvalue1Úattrib1zuser@host/resourceÚattrib3ÚsomecontentÚbarr   ÚgarÚDEFÚsomemorecontentÚvalue2Úattrib2ÚABCÚvalue4Úattrib4Úvalue5Úattrib5ÚJKLÚMNOÚvalue6õ   Ã¡Úattrib6Úquuxu   â˜ƒ)r   ÚeÚ
addContentÚ
addElementÚbar1ÚsubfooÚgar1Úbar2Úbar3Úsubfoo2Úgar2Úbar4Úbar5Úsubfoo3Úgar3Úbar6Úsubfoo4Úgar4Úbar7r"   ©Úselfs    ú\/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/words/test/test_xpath.pyÚsetUpzXPathTests.setUp   s�  € õ8 Ð*Ñ+Ô+ˆŒØ$ˆŒˆyÑØ0ˆŒˆyÑØŒ×Ò˜-Ñ(Ô(Ð(Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø”i×*Ò*¨5Ñ1Ô1ˆŒØ”K×*Ò*¨5Ñ1Ô1ˆŒ	ØŒ	×Ò˜UÑ#Ô#Ð#ØŒ×ÒÐ+Ñ,Ô,Ð,Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø'ˆŒ	�)ÑØ”I×(Ò(¨Ñ/Ô/ˆŒ	Ø”y×+Ò+¨EÑ2Ô2ˆŒØ”I×(Ò(¨Ñ/Ô/ˆŒ	ØŒ	×Ò˜UÑ#Ô#Ð#Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø'ˆŒ	�)ÑØ'ˆŒ	�)ÑØ”y×+Ò+¨EÑ2Ô2ˆŒØ”I×(Ò(¨Ñ/Ô/ˆŒ	ØŒ	×Ò˜UÑ#Ô#Ð#Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø'ˆŒ	�)ÑØ'ˆŒ	�)ÑØ”y×+Ò+¨EÑ2Ô2ˆŒØ”I×(Ò(¨Ñ/Ô/ˆŒ	ØŒ	×Ò˜UÑ#Ô#Ð#Ø”F×%Ò% eÑ,Ô,ˆŒ	Ø'ˆŒ	�)ÑØ'ˆŒ	�)ÑØ#ˆŒ	�)ÑØ”I×(Ò(¨Ñ0Ô0ˆŒ	ØŒ	×Ò˜]Ñ+Ô+Ð+Ð+Ð+ó    c           	      óÂ  — |                       t          j        d| j        ¦  «        d¦  «         |                       t          j        d| j        ¦  «        | j        | j        | j        | j        | j	        | j
        g¦  «         |                       t          j        d| j        ¦  «        d¦  «         |                       t          j        d| j        ¦  «        ddg¦  «         dS )z=
        Test basic operation of the static methods.
        ú/foo/barTú/foor   r   N)ÚassertEqualr   Úmatchesr#   ÚqueryForNodesr&   r)   r-   r.   r1   r4   ÚqueryForStringÚqueryForStringListr5   s    r7   Útest_staticMethodszXPathTests.test_staticMethodsL   sÑ   € ð 	×Ò�œ z°4´6Ñ:Ô:¸DÑAÔAÐAØ×ÒÝÔ 
¨D¬FÑ3Ô3ØŒY˜œ	 4¤9¨d¬i¸¼ÀDÄIÐNñ	
ô 	
ð 	
ð 	×Ò�Ô-¨f°d´fÑ=Ô=¸}ÑMÔMÐMØ×ÒÝÔ$ V¨T¬VÑ4Ô4°}ÐFWÐ6Xñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z3
        Test matching foo with child bar.
        r;   é   N©r   r=   r>   r#   ©r6   Úxps     r7   Útest_locationFooBarzXPathTests.test_locationFooBarZ   s;   € õ ˜
Ñ#Ô#ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨QÑ/Ô/Ð/Ð/Ð/r9   c                 ó   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        | j        g¦  «         dS )z8
        Test finding foos at the second level.
        z/foo/bar/foorD   N)r   r=   r>   r#   r?   r'   r/   r2   rF   s     r7   Útest_locationFooBarFooz!XPathTests.test_locationFooBarFooa   sy   € õ ˜Ñ'Ô'ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨QÑ/Ô/Ð/Ø×ÒØ×Ò˜TœVÑ$Ô$ t¤{°D´LÀ$Ä,Ð&Oñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z(
        Test not finding bar3.
        z	/foo/bar3r   NrE   rF   s     r7   Útest_locationNoBar3zXPathTests.test_locationNoBar3k   s;   € õ ˜Ñ$Ô$ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨QÑ/Ô/Ð/Ð/Ð/r9   c           	      ó$  — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        | j        | j        | j	        | j
        g¦  «         dS )z-
        Test finding childs of foo.
        z/foo/*TN)r   r=   r>   r#   r?   r&   r)   r-   r.   r1   r4   rF   s     r7   Útest_locationAllChildsz!XPathTests.test_locationAllChildsr   s†   € õ ˜Ñ!Ô!ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×ÒØ×Ò˜TœVÑ$Ô$ØŒY˜œ	 4¤9¨d¬i¸¼ÀDÄIÐNñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z3
        Test matching foo with attribute.
        z/foo[@attrib1]TNrE   rF   s     r7   Útest_attributezXPathTests.test_attribute}   s<   € õ Ð(Ñ)Ô)ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ð2Ð2r9   c                 óè   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        g¦  «         dS )z>
        Test find nodes with attribute having value.
        z/foo/*[@attrib2='value2']TN)r   r=   r>   r#   r?   r)   rF   s     r7   Útest_attributeWithValueAnyz%XPathTests.test_attributeWithValueAny„   óf   € õ Ð3Ñ4Ô4ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I°;Ñ?Ô?Ð?Ð?Ð?r9   c                 óè   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        g¦  «         dS )zI
        Nodes' attributes can be matched with non-ASCII values.
        u   /foo/*[@attrib6='Ã¡']TN)r   r=   r>   r#   r?   r4   rF   s     r7   Útest_locationWithValueUnicodez(XPathTests.test_locationWithValueUnicodeŒ   sf   € õ Ð/Ñ0Ô0ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I°;Ñ?Ô?Ð?Ð?Ð?r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z4
        Test matching node with namespace.
        z/foo[@xmlns='testns']/barrD   NrE   rF   s     r7   Útest_namespaceFoundzXPathTests.test_namespaceFound”   ó<   € õ Ð3Ñ4Ô4ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨QÑ/Ô/Ð/Ð/Ð/r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z>
        Test not matching node with wrong namespace.
        z/foo[@xmlns='badns']/bar2r   NrE   rF   s     r7   Útest_namespaceNotFoundz!XPathTests.test_namespaceNotFound›   rX   r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )zA
        Test matching node with attribute having value.
        z/foo[@attrib1='value1']rD   NrE   rF   s     r7   Útest_attributeWithValuez"XPathTests.test_attributeWithValue¢   s<   € õ Ð1Ñ2Ô2ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨QÑ/Ô/Ð/Ð/Ð/r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )zM
        queryforString on absolute paths returns their first CDATA.
        r<   r   N)r   r=   r@   r#   rF   s     r7   Útest_queryForStringzXPathTests.test_queryForString©   s=   € õ ˜ÑÔˆØ×Ò˜×*Ò*¨4¬6Ñ2Ô2°MÑBÔBÐBÐBÐBr9   c                 ó„   — t          d¦  «        }|                      |                     | j        ¦  «        ddg¦  «         dS )zO
        queryforStringList on absolute paths returns all their CDATA.
        r<   r   r   N©r   r=   rA   r#   rF   s     r7   Útest_queryForStringListz"XPathTests.test_queryForStringList°   sN   € õ ˜ÑÔˆØ×ÒØ×!Ò! $¤&Ñ)Ô)¨MÐ;LÐ+Mñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 ó„   — t          d¦  «        }|                      |                     | j        ¦  «        ddg¦  «         dS )zO
        queryforStringList on relative paths returns all their CDATA.
        z//foor   r   Nr`   rF   s     r7   Ú"test_queryForStringListAnyLocationz-XPathTests.test_queryForStringListAnyLocation¹   sN   € õ ˜Ñ Ô ˆØ×ÒØ×!Ò! $¤&Ñ)Ô)¨MÐ;LÐ+Mñ	
ô 	
ð 	
ð 	
ð 	
r9   c           	      óÈ   — t          d¦  «        }|                      |                     | j        ¦  «        | j        | j        | j        | j        | j        | j	        g¦  «         dS )z%
        Test finding nodes.
        r;   N)
r   r=   r?   r#   r&   r)   r-   r.   r1   r4   rF   s     r7   Útest_queryForNodeszXPathTests.test_queryForNodesÂ   sb   € õ ˜
Ñ#Ô#ˆØ×ÒØ×Ò˜TœVÑ$Ô$ØŒY˜œ	 4¤9¨d¬i¸¼ÀDÄIÐNñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z7
        Test matching a node with given text.
        z/foo[text() = 'somecontent']TNrE   rF   s     r7   Útest_textConditionzXPathTests.test_textConditionÌ   s<   € õ Ð6Ñ7Ô7ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ð2Ð2r9   c                 óè   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        g¦  «         dS )zK
        A node can be matched by text with non-ascii code points.
        u   //*[text()='â˜ƒ']TN)r   r=   r>   r#   r?   r"   rF   s     r7   Útest_textConditionUnicodez$XPathTests.test_textConditionUnicodeÓ   rS   r9   c                 ó€   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         dS )z(
        Test for not operator.
        z/foo[not(@nosuchattrib)]TNrE   rF   s     r7   Útest_textNotOperatorzXPathTests.test_textNotOperatorÛ   s<   € õ Ð2Ñ3Ô3ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ð2Ð2r9   c                 ól  — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        | j        | j        g¦  «         |                      | 	                    | j        ¦  «        g d¢¦  «         dS )zS
        Test finding any nodes named gar and getting their text contents.
        z//garT)r   r   r   r   N)
r   r=   r>   r#   r?   r(   r,   r0   r3   rA   rF   s     r7   Útest_anyLocationAndTextz"XPathTests.test_anyLocationAndTextâ   s¨   € õ ˜Ñ Ô ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×ÒØ×Ò˜TœVÑ$Ô$ t¤y°$´)¸T¼YÈÌ	Ð&Rñ	
ô 	
ð 	
ð 	×Ò˜×.Ò.¨t¬vÑ6Ô6Ð8TÐ8TÐ8TÑUÔUÐUÐUÐUr9   c           
      ó0  — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        | j        | j        | j	        | j
        | j        g¦  «         dS )z3
        Test finding any nodes named bar.
        ú//barTN)r   r=   r>   r#   r?   r&   r)   r*   r-   r.   r1   r4   rF   s     r7   Útest_anyLocationzXPathTests.test_anyLocationí   s’   € õ ˜Ñ Ô ˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×ÒØ×Ò˜TœVÑ$Ô$à”	Ø”	Ø”	Ø”	Ø”	Ø”	Ø”	ðñ	
ô 	
ð 	
ð 	
ð 	
r9   c                 óf   — t          d¦  «        }|                      t          |j        d¦  «         dS )zn
        L{XPathQuery.queryForString} should raise a L{NotImplementedError}
        for any location.
        ro   N)r   ÚassertRaisesÚNotImplementedErrorr@   rF   s     r7   Útest_anyLocationQueryForStringz)XPathTests.test_anyLocationQueryForString   s3   € õ
 ˜Ñ Ô ˆØ×ÒÕ-¨rÔ/@À$ÑGÔGÐGÐGÐGr9   c                 óè   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        g¦  «         dS )z9
        Test boolean and operator in condition.
        z.//bar[@attrib4='value4' and @attrib5='value5']TN)r   r=   r>   r#   r?   r.   rF   s     r7   Útest_andOperatorzXPathTests.test_andOperator  sf   € õ ÐHÑIÔIˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I°;Ñ?Ô?Ð?Ð?Ð?r9   c                 óô   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        g¦  «         dS )z8
        Test boolean or operator in condition.
        z-//bar[@attrib5='value4' or @attrib5='value5']TN)r   r=   r>   r#   r?   r.   r1   rF   s     r7   Útest_orOperatorzXPathTests.test_orOperator  sk   € õ ÐGÑHÔHˆØ×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I¸t¼yÐ3IÑJÔJÐJÐJÐJr9   c                 óô   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        g¦  «         dS )zK
        Test multiple boolean operators in condition with parens.
        zf//bar[@attrib4='value4' and
                                 (@attrib5='value4' or @attrib5='value6')]TN)r   r=   r>   r#   r?   r1   r4   rF   s     r7   Útest_booleanOperatorsParensz&XPathTests.test_booleanOperatorsParens  st   € õ ðNñ
ô 
ˆð 	×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I¸t¼yÐ3IÑJÔJÐJÐJÐJr9   c                 ó   — t          d¦  «        }|                      |                     | j        ¦  «        d¦  «         |                      |                     | j        ¦  «        | j        | j        | j        g¦  «         dS )zN
        Test multiple boolean operators in condition without parens.
        z„//bar[@attrib5='value4' or
                                 @attrib5='value5' or
                                 @attrib5='value6']TN)r   r=   r>   r#   r?   r.   r1   r4   rF   s     r7   Útest_booleanOperatorsNoParensz(XPathTests.test_booleanOperatorsNoParens#  sw   € õ ð7ñ
ô 
ˆð
 	×Ò˜Ÿš D¤FÑ+Ô+¨TÑ2Ô2Ð2Ø×Ò˜×)Ò)¨$¬&Ñ1Ô1°D´I¸t¼yÈ$Ì)Ð3TÑUÔUÐUÐUÐUr9   c                 ó´   — |                       t          t          d¦  «        }|                      |j                             d¦  «        d|j        z  ¦  «         dS )z}
        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)rr   r   r   Ú
assertTrueÚmsgÚ
startswith)r6   Úexcs     r7   Útest_badXPathNoClosingBracketz(XPathTests.test_badXPathNoClosingBracket/  s]   € ð ×Ò¥­ZÐ9MÑNÔNˆØ�ŠØŒG×ÒÐ6Ñ7Ô7ØUØŒgññ	
ô 	
ð 	
ð 	
ð 	
r9   )r
   N)Ú__name__Ú
__module__Ú__qualname__r8   rB   rH   rJ   rL   rN   rP   rR   rU   rW   rZ   r\   r^   ra   rc   re   rg   ri   rk   rm   rp   rt   rv   rx   rz   r|   r‚   © r9   r7   r	   r	      sY  € € € € € ð=,ð =,ð =,ð =,ð~
ð 
ð 
ð 
ð0ð 0ð 0ð 0ð
ð 
ð 
ð 
ð0ð 0ð 0ð 0ð	
ð 	
ð 	
ð 	
ð3ð 3ð 3ð 3ð@ð @ð @ð @ð@ð @ð @ð @ð0ð 0ð 0ð 0ð0ð 0ð 0ð 0ð0ð 0ð 0ð 0ðCð Cð Cð Cð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð3ð 3ð 3ð 3ð@ð @ð @ð @ð3ð 3ð 3ð 3ð	Vð 	Vð 	Vð 	Vð
ð 
ð 
ð 
ð&Hð Hð Hð Hð@ð @ð @ð @ðKð Kð Kð Kð	Kð 	Kð 	Kð 	Kð
Vð 
Vð 
Vð 
Vð
ð 
ð 
ð 
ð 
ð 
r9   r	   N)Útwisted.trialr   Útwisted.words.xishr   Útwisted.words.xish.domishr   Útwisted.words.xish.xpathr   Útwisted.words.xish.xpathparserr   ÚTestCaser	   r†   r9   r7   ú<module>r�      s¢   ðð
 #Ð "Ð "Ð "Ð "Ð "Ø $Ð $Ð $Ð $Ð $Ð $Ø -Ð -Ð -Ð -Ð -Ð -Ø /Ð /Ð /Ð /Ð /Ð /Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6ðn
ð n
ð n
ð n
ð n
�Ô"ñ n
ô n
ð n
ð n
ð n
r9   