HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/twisted/words/test/__pycache__/test_xpath.cpython-38.pyc
U


W[�*�@sbddlmZmZddlmZddlmZddlmZddl	m
Z
ddlmZGdd�dej
�Zd	S)
�)�absolute_import�division)�unittest)�xpath)�Element)�
XPathQuery)�SyntaxErrorc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7S)8�
XPathTestscCs�td�|_d|jd<d|jd<|j�d�|j�d�|_|j�d�|_|j�d	�|_|j�d
�|j�d�|j�d�|_d|jd
<|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|jd<d|jd<|j�d�|_|j�d	�|_|j�d�|j�d�|_d|jd<d|jd<d|jd<|j�d�|_|j�d�dS)N)Ztestns�fooZvalue1Zattrib1zuser@host/resourceZattrib3�somecontentZbarr
Zgar�DEF�somemorecontentZvalue2Zattrib2�ABCZvalue4Zattrib4Zvalue5Zattrib5�JKL�MNOZvalue6�áZattrib6�quuxu☃)r�eZ
addContentZ
addElement�bar1�subfoo�gar1�bar2�bar3Zsubfoo2�gar2�bar4�bar5�subfoo3�gar3�bar6�subfoo4�gar4�bar7r��self�r$�?/usr/lib/python3/dist-packages/twisted/words/test/test_xpath.py�setUpsD










zXPathTests.setUpc	Csx|�t�d|j�d�|�t�d|j�|j|j|j|j|j	|j
g�|�t�d|j�d�|�t�d|j�ddg�dS)z=
        Test basic operation of the static methods.
        �/foo/barT�/foorr
N)
�assertEqualr�matchesr�
queryForNodesrrrrrr!�queryForString�queryForStringListr"r$r$r%�test_staticMethodsNs �����zXPathTests.test_staticMethodscCs td�}|�|�|j�d�dS)z3
        Test matching foo with child bar.
        r'�N�rr)r*r�r#Zxpr$r$r%�test_locationFooBar\szXPathTests.test_locationFooBarcCs@td�}|�|�|j�d�|�|�|j�|j|j|jg�dS)z8
        Test finding foos at the second level.
        z/foo/bar/foor/N)rr)r*rr+rrrr1r$r$r%�test_locationFooBarFoocs�z!XPathTests.test_locationFooBarFoocCs td�}|�|�|j�d�dS)z(
        Test not finding bar3.
        z	/foo/bar3rNr0r1r$r$r%�test_locationNoBar3mszXPathTests.test_locationNoBar3c	CsLtd�}|�|�|j�d�|�|�|j�|j|j|j|j|j	|j
g�dS)z-
        Test finding childs of foo.
        z/foo/*TN)rr)r*rr+rrrrrr!r1r$r$r%�test_locationAllChildsts�z!XPathTests.test_locationAllChildscCs td�}|�|�|j�d�dS)z3
        Test matching foo with attribute.
        z/foo[@attrib1]TNr0r1r$r$r%�test_attribute~szXPathTests.test_attributecCs8td�}|�|�|j�d�|�|�|j�|jg�dS)z>
        Test find nodes with attribute having value.
        z/foo/*[@attrib2='value2']TN)rr)r*rr+rr1r$r$r%�test_attributeWithValueAny�sz%XPathTests.test_attributeWithValueAnycCs8td�}|�|�|j�d�|�|�|j�|jg�dS)zI
        Nodes' attributes can be matched with non-ASCII values.
        u/foo/*[@attrib6='á']TN)rr)r*rr+r!r1r$r$r%�test_locationWithValueUnicode�sz(XPathTests.test_locationWithValueUnicodecCs td�}|�|�|j�d�dS)z4
        Test matching node with namespace.
        z/foo[@xmlns='testns']/barr/Nr0r1r$r$r%�test_namespaceFound�szXPathTests.test_namespaceFoundcCs td�}|�|�|j�d�dS)z>
        Test not matching node with wrong namespace.
        z/foo[@xmlns='badns']/bar2rNr0r1r$r$r%�test_namespaceNotFound�sz!XPathTests.test_namespaceNotFoundcCs td�}|�|�|j�d�dS)zA
        Test matching node with attribute having value.
        z/foo[@attrib1='value1']r/Nr0r1r$r$r%�test_attributeWithValue�sz"XPathTests.test_attributeWithValuecCs td�}|�|�|j�d�dS)zM
        queryforString on absolute paths returns their first CDATA.
        r(rN)rr)r,rr1r$r$r%�test_queryForString�szXPathTests.test_queryForStringcCs$td�}|�|�|j�ddg�dS)zO
        queryforStringList on absolute paths returns all their CDATA.
        r(rr
N�rr)r-rr1r$r$r%�test_queryForStringList�s�z"XPathTests.test_queryForStringListcCs$td�}|�|�|j�ddg�dS)zO
        queryforStringList on relative paths returns all their CDATA.
        z//foorr
Nr=r1r$r$r%�"test_queryForStringListAnyLocation�s�z-XPathTests.test_queryForStringListAnyLocationc	Cs8td�}|�|�|j�|j|j|j|j|j|j	g�dS)z%
        Test finding nodes.
        r'N)
rr)r+rrrrrrr!r1r$r$r%�test_queryForNodes�s�zXPathTests.test_queryForNodescCs td�}|�|�|j�d�dS)z7
        Test matching a node with given text.
        z/foo[text() = 'somecontent']TNr0r1r$r$r%�test_textCondition�szXPathTests.test_textConditioncCs8td�}|�|�|j�d�|�|�|j�|jg�dS)zK
        A node can be matched by text with non-ascii code points.
        u//*[text()='☃']TN)rr)r*rr+rr1r$r$r%�test_textConditionUnicode�sz$XPathTests.test_textConditionUnicodecCs td�}|�|�|j�d�dS)z(
        Test for not operator.
        z/foo[not(@nosuchattrib)]TNr0r1r$r$r%�test_textNotOperator�szXPathTests.test_textNotOperatorcCs`td�}|�|�|j�d�|�|�|j�|j|j|j|jg�|�|�	|j�ddddg�dS)zS
        Test finding any nodes named gar and getting their text contents.
        z//garTrrrrN)
rr)r*rr+rrrr r-r1r$r$r%�test_anyLocationAndText�s��z"XPathTests.test_anyLocationAndTextc
CsPtd�}|�|�|j�d�|�|�|j�|j|j|j|j|j	|j
|jg�dS)z3
        Test finding any nodes named bar.
        �//barTN)rr)r*rr+rrrrrrr!r1r$r$r%�test_anyLocation�s�zXPathTests.test_anyLocationcCstd�}|�t|jd�dS)zn
        L{XPathQuery.queryForString} should raise a L{NotImplementedError}
        for any location.
        rEN)r�assertRaises�NotImplementedErrorr,r1r$r$r%�test_anyLocationQueryForString�sz)XPathTests.test_anyLocationQueryForStringcCs8td�}|�|�|j�d�|�|�|j�|jg�dS)z9
        Test boolean and operator in condition.
        z.//bar[@attrib4='value4' and @attrib5='value5']TN)rr)r*rr+rr1r$r$r%�test_andOperator�szXPathTests.test_andOperatorcCs<td�}|�|�|j�d�|�|�|j�|j|jg�dS)z8
        Test boolean or operator in condition.
        z-//bar[@attrib5='value4' or @attrib5='value5']TN)rr)r*rr+rrr1r$r$r%�test_orOperatorszXPathTests.test_orOperatorcCs<td�}|�|�|j�d�|�|�|j�|j|jg�dS)zK
        Test multiple boolean operators in condition with parens.
        zf//bar[@attrib4='value4' and
                                 (@attrib5='value4' or @attrib5='value6')]TN)rr)r*rr+rr!r1r$r$r%�test_booleanOperatorsParenssz&XPathTests.test_booleanOperatorsParenscCs@td�}|�|�|j�d�|�|�|j�|j|j|jg�dS)zN
        Test multiple boolean operators in condition without parens.
        z�//bar[@attrib5='value4' or
                                 @attrib5='value5' or
                                 @attrib5='value6']TN)rr)r*rr+rrr!r1r$r$r%�test_booleanOperatorsNoParenssz(XPathTests.test_booleanOperatorsNoParenscCs,|�ttd�}|�|j�d�d|j�dS)z}
        A missing closing bracket raises a SyntaxError.

        This test excercises the most common failure mode.
        z//bar[@attrib1zTrying to find one ofzCSyntaxError message '%s' doesn't start with 'Trying to find one of'N)rGrrZ
assertTrue�msg�
startswith)r#�excr$r$r%�test_badXPathNoClosingBracket!s��z(XPathTests.test_badXPathNoClosingBracketN)�__name__�
__module__�__qualname__r&r.r2r3r4r5r6r7r8r9r:r;r<r>r?r@rArBrCrDrFrIrJrKrLrMrQr$r$r$r%r	s6?

		
r	N)Z
__future__rrZ
twisted.trialrZtwisted.words.xishrZtwisted.words.xish.domishrZtwisted.words.xish.xpathrZtwisted.words.xish.xpathparserrZTestCaser	r$r$r$r%�<module>s