%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/words/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/words/test/__pycache__/test_xpath.cpython-312.pyc

�

Ϫ�f=*��j�ddlmZddlmZddlmZddlmZddlm	Z	Gd�dej�Zy)	�)�unittest)�xpath)�Element)�
XPathQuery)�SyntaxErrorc���eZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zdd�Zdd�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy)�
XPathTestsNc���td�|_d|jd<d|jd<|jjd�|jjd�|_|jjd�|_|j
jd	�|_|jjd
�|jjd�|jjd�|_d|jd
<|jjd�|_|jjd�|_	|jjd	�|_
|jjd�|jjd�|_|jjd�|_d|jd<d|jd<|jjd�|_
|jjd	�|_|jjd�|jjd�|_d|jd<d|jd<|jjd�|_|jjd	�|_|j"jd�|jjd�|_d|j$d<d|j$d<d|j$d<|j$jd�|_|j&jd�y)N)�testns�foo�value1�attrib1zuser@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 �?/usr/lib/python3/dist-packages/twisted/words/test/test_xpath.py�setUpzXPathTests.setUp
s|��8�*�+���$����y��0����y�������-�(��F�F�%�%�e�,��	��i�i�*�*�5�1����K�K�*�*�5�1��	��	�	���U�#������+�,��F�F�%�%�e�,��	�'��	�	�)���I�I�(�(��/��	��y�y�+�+�E�2����I�I�(�(��/��	��	�	���U�#��F�F�%�%�e�,��	��F�F�%�%�e�,��	�'��	�	�)��'��	�	�)���y�y�+�+�E�2����I�I�(�(��/��	��	�	���U�#��F�F�%�%�e�,��	�'��	�	�)��'��	�	�)���y�y�+�+�E�2����I�I�(�(��/��	��	�	���U�#��F�F�%�%�e�,��	�'��	�	�)��'��	�	�)��#��	�	�)���I�I�(�(��0��	��	�	���]�+�c	��|jtjd|j�d�|jtjd|j�|j
|j|j|j|j|jg�|jtjd|j�d�|jtjd|j�ddg�y)z=
        Test basic operation of the static methods.
        �/foo/barT�/foorrN)
�assertEqualr�matchesr"�
queryForNodesr%r(r,r-r0r3�queryForString�queryForStringListr4s r6�test_staticMethodszXPathTests.test_staticMethodsLs���	
������z�4�6�6�:�D�A�������
�D�F�F�3�
�Y�Y��	�	�4�9�9�d�i�i����D�I�I�N�	
�	
����-�-�f�d�f�f�=�}�M�����$�$�V�T�V�V�4�}�FW�6X�	
r8c�p�td�}|j|j|j�d�y)z3
        Test matching foo with child bar.
        r:�N�rr<r=r"�r5�xps  r6�test_locationFooBarzXPathTests.test_locationFooBarZs+���
�
#��������D�F�F�+�Q�/r8c��td�}|j|j|j�d�|j|j	|j�|j
|j|jg�y)z8
        Test finding foos at the second level.
        z/foo/bar/foorCN)rr<r=r"r>r&r.r1rEs  r6�test_locationFooBarFooz!XPathTests.test_locationFooBarFooas`����
'��������D�F�F�+�Q�/�������T�V�V�$�t�{�{�D�L�L�$�,�,�&O�	
r8c�p�td�}|j|j|j�d�y)z(
        Test not finding bar3.
        z	/foo/bar3rNrDrEs  r6�test_locationNoBar3zXPathTests.test_locationNoBar3ks+����
$��������D�F�F�+�Q�/r8c	�J�td�}|j|j|j�d�|j|j	|j�|j
|j|j|j|j|jg�y)z-
        Test finding childs of foo.
        z/foo/*TN)rr<r=r"r>r%r(r,r-r0r3rEs  r6�test_locationAllChildsz!XPathTests.test_locationAllChildsrss����
!��������D�F�F�+�T�2�������T�V�V�$�
�Y�Y��	�	�4�9�9�d�i�i����D�I�I�N�	
r8c�p�td�}|j|j|j�d�y)z3
        Test matching foo with attribute.
        z/foo[@attrib1]TNrDrEs  r6�test_attributezXPathTests.test_attribute}s,���(�
)��������D�F�F�+�T�2r8c���td�}|j|j|j�d�|j|j	|j�|j
g�y)z>
        Test find nodes with attribute having value.
        z/foo/*[@attrib2='value2']TN)rr<r=r"r>r(rEs  r6�test_attributeWithValueAnyz%XPathTests.test_attributeWithValueAny��Q���3�
4��������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�;�?r8c���td�}|j|j|j�d�|j|j	|j�|j
g�y)zI
        Nodes' attributes can be matched with non-ASCII values.
        u/foo/*[@attrib6='á']TN)rr<r=r"r>r3rEs  r6�test_locationWithValueUnicodez(XPathTests.test_locationWithValueUnicode�sQ���/�
0��������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�;�?r8c�p�td�}|j|j|j�d�y)z4
        Test matching node with namespace.
        z/foo[@xmlns='testns']/barrCNrDrEs  r6�test_namespaceFoundzXPathTests.test_namespaceFound��,���3�
4��������D�F�F�+�Q�/r8c�p�td�}|j|j|j�d�y)z>
        Test not matching node with wrong namespace.
        z/foo[@xmlns='badns']/bar2rNrDrEs  r6�test_namespaceNotFoundz!XPathTests.test_namespaceNotFound�rWr8c�p�td�}|j|j|j�d�y)zA
        Test matching node with attribute having value.
        z/foo[@attrib1='value1']rCNrDrEs  r6�test_attributeWithValuez"XPathTests.test_attributeWithValue�s,���1�
2��������D�F�F�+�Q�/r8c�p�td�}|j|j|j�d�y)zM
        queryforString on absolute paths returns their first CDATA.
        r;rN)rr<r?r"rEs  r6�test_queryForStringzXPathTests.test_queryForString�s-����
������*�*�4�6�6�2�M�Br8c�t�td�}|j|j|j�ddg�y)zO
        queryforStringList on absolute paths returns all their CDATA.
        r;rrN�rr<r@r"rEs  r6�test_queryForStringListz"XPathTests.test_queryForStringList�s6����
������!�!�$�&�&�)�M�;L�+M�	
r8c�t�td�}|j|j|j�ddg�y)zO
        queryforStringList on relative paths returns all their CDATA.
        z//foorrNr_rEs  r6�"test_queryForStringListAnyLocationz-XPathTests.test_queryForStringListAnyLocation�s6����
 ������!�!�$�&�&�)�M�;L�+M�	
r8c	���td�}|j|j|j�|j|j
|j|j|j|jg�y)z%
        Test finding nodes.
        r:N)
rr<r>r"r%r(r,r-r0r3rEs  r6�test_queryForNodeszXPathTests.test_queryForNodes�sV���
�
#��������T�V�V�$�
�Y�Y��	�	�4�9�9�d�i�i����D�I�I�N�	
r8c�p�td�}|j|j|j�d�y)z7
        Test matching a node with given text.
        z/foo[text() = 'somecontent']TNrDrEs  r6�test_textConditionzXPathTests.test_textCondition�s,���6�
7��������D�F�F�+�T�2r8c���td�}|j|j|j�d�|j|j	|j�|j
g�y)zK
        A node can be matched by text with non-ascii code points.
        u//*[text()='☃']TN)rr<r=r"r>r!rEs  r6�test_textConditionUnicodez$XPathTests.test_textConditionUnicode�rRr8c�p�td�}|j|j|j�d�y)z(
        Test for not operator.
        z/foo[not(@nosuchattrib)]TNrDrEs  r6�test_textNotOperatorzXPathTests.test_textNotOperator�s,���2�
3��������D�F�F�+�T�2r8c�x�td�}|j|j|j�d�|j|j	|j�|j
|j|j|jg�|j|j|j�gd��y)zS
        Test finding any nodes named gar and getting their text contents.
        z//garT)rrrrN)
rr<r=r"r>r'r+r/r2r@rEs  r6�test_anyLocationAndTextz"XPathTests.test_anyLocationAndText�s�����
 ��������D�F�F�+�T�2�������T�V�V�$�t�y�y�$�)�)�T�Y�Y��	�	�&R�	
�	
����.�.�t�v�v�6�8T�Ur8c
�`�td�}|j|j|j�d�|j|j	|j�|j
|j|j|j|j|j|jg�y)z3
        Test finding any nodes named bar.
        �//barTN)rr<r=r"r>r%r(r)r,r-r0r3rEs  r6�test_anyLocationzXPathTests.test_anyLocation�s�����
 ��������D�F�F�+�T�2�������T�V�V�$��	�	��	�	��	�	��	�	��	�	��	�	��	�	�
�	
r8c�\�td�}|jt|jd�y)zn
        L{XPathQuery.queryForString} should raise a L{NotImplementedError}
        for any location.
        rnN)r�assertRaises�NotImplementedErrorr?rEs  r6�test_anyLocationQueryForStringz)XPathTests.test_anyLocationQueryForStrings'��
��
 �����-�r�/@�/@�$�Gr8c���td�}|j|j|j�d�|j|j	|j�|j
g�y)z9
        Test boolean and operator in condition.
        z.//bar[@attrib4='value4' and @attrib5='value5']TN)rr<r=r"r>r-rEs  r6�test_andOperatorzXPathTests.test_andOperatorsQ���H�
I��������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�;�?r8c���td�}|j|j|j�d�|j|j	|j�|j
|jg�y)z8
        Test boolean or operator in condition.
        z-//bar[@attrib5='value4' or @attrib5='value5']TN)rr<r=r"r>r-r0rEs  r6�test_orOperatorzXPathTests.test_orOperatorsX���G�
H��������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�t�y�y�3I�Jr8c���td�}|j|j|j�d�|j|j	|j�|j
|jg�y)zK
        Test multiple boolean operators in condition with parens.
        zf//bar[@attrib4='value4' and
                                 (@attrib5='value4' or @attrib5='value6')]TN)rr<r=r"r>r0r3rEs  r6�test_booleanOperatorsParensz&XPathTests.test_booleanOperatorsParenss_���
N�
��	
������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�t�y�y�3I�Jr8c��td�}|j|j|j�d�|j|j	|j�|j
|j|jg�y)zN
        Test multiple boolean operators in condition without parens.
        z�//bar[@attrib5='value4' or
                                 @attrib5='value5' or
                                 @attrib5='value6']TN)rr<r=r"r>r-r0r3rEs  r6�test_booleanOperatorsNoParensz(XPathTests.test_booleanOperatorsNoParens#sd���
7�
��
	
������D�F�F�+�T�2�����)�)�$�&�&�1�D�I�I�t�y�y�$�)�)�3T�Ur8c��|jttd�}|j|jjd�d|jz�y)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)rqrr�
assertTrue�msg�
startswith)r5�excs  r6�test_badXPathNoClosingBracketz(XPathTests.test_badXPathNoClosingBracket/sG������Z�9M�N������G�G���6�7�
U��g�g�
�	
r8)�returnN)�__name__�
__module__�__qualname__r7rArGrIrKrMrOrQrTrVrYr[r]r`rbrdrfrhrjrlrorsrurwryr{r��r8r6r	r	s���=,�~
�0�
�0�	
�3�@�@�0�0�0�C�
�
�
�3�@�3�	V�
�&H�@�K�	K�
V�
r8r	N)�
twisted.trialr�twisted.words.xishr�twisted.words.xish.domishr�twisted.words.xish.xpathr�twisted.words.xish.xpathparserr�TestCaser	r�r8r6�<module>r�s*��
#�$�-�/�6�n
��"�"�n
r8

Zerion Mini Shell 1.0