Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_pulldom.cpython-311.opt-1.pyc
�

�KeT1��j�ddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZedd���Zd	Z
Gd
�dej��ZGd�d
ej��ZGd�de��ZGd�de��ZGd�de	j��ZGd�dej��Zedkrej��dSdS)�N)�AttributesImpl)�feature_external_ges)�pulldom)�findfileztest.xml�xmltestdata)�subdira
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xdc="http://www.xml.com/books">
<!-- A comment -->
<title>Introduction to XSL</title>
<hr/>
<p><xdc:author xdc:attrib="prefixed attribute" attrib="other attrib">A. Namespace</xdc:author></p>
</html>c�f�eZdZd�Zd�Zd�Zejd���Zejd���Z	d�Z
dS)�PullDOMTestCasec�2�tjt��}|�|jj��t
|��ttd��5}t
tj|����ddd��dS#1swxYwYdS)z&Minimal test of DOMEventStream.parse()�rbN)r�parse�tstfile�
addCleanup�stream�close�list�open)�self�handler�fins   �;/usr/local/apps/python3/lib/python3.11/test/test_pulldom.py�
test_parsezPullDOMTestCase.test_parses����-��(�(�������,�-�-�-��W�
�
�
��'�4�
 �
 �	%�C����s�#�#�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�"B�B�Bc�
�tjt��}t|��\}}|�t|d����|�tj|��t|��\}}|�tj|��|�d|j	��|�dt|j����|�|j�d��j
d��t|��\}}|�tj|��t|��\}}|�tj|��t|��\}}|�d|j	��|}t|��\}}|�tj|��|�d|j��t|��\}}|�tj|��|�d|j	��|�||u��t|��\}}|�tj|��t|��\}}|�tj|��|�d|j	��t|��\}}|�tj|��|�d|j	��t|��\}}|�tj|��t|��\}}|�tj|��|�d	|j	��t|��\}}|�tj|��|�d
|j	��t|��\}}|�tj|��t|��\}}|�tj|��|�d
|j	��t|��\}}|�tj|��t|��\}}|�tj|��t|��\}}|�tj|��dS)z&Test DOMEventStream parsing semantics.�
createElement�html�z	xmlns:xdczhttp://www.xml.com/books�titlezIntroduction to XSL�hr�pz
xdc:authorN)r�parseString�SMALL_SAMPLE�next�
assertTrue�hasattr�assertEqual�START_DOCUMENT�
START_ELEMENT�tagName�len�
attributes�getNamedItem�value�
CHARACTERS�data�END_ELEMENT)r�items�evt�node�
title_nodes     r�test_parse_semanticsz$PullDOMTestCase.test_parse_semantics+s4���#�L�1�1����K�K�	��T������o�6�6�7�7�7�����/��5�5�5���K�K�	��T�����.��4�4�4�������.�.�.�����C���0�0�1�1�1������5�5�k�B�B�H�(�	*�	*�	*���K�K�	��T�����+�S�1�1�1���K�K�	��T�	
����+�S�1�1�1���K�K�	��T�����$�,�/�/�/��
���K�K�	��T�����+�S�1�1�1����.��	�:�:�:���K�K�	��T�����,�c�2�2�2�����$�,�/�/�/����
�d�*�+�+�+���K�K�	��T�����+�S�1�1�1���K�K�	��T�����.��4�4�4�����t�|�,�,�,���K�K�	��T�����,�c�2�2�2�����t�|�,�,�,���K�K�	��T�����+�S�1�1�1���K�K�	��T�����.��4�4�4�����d�l�+�+�+���K�K�	��T�����.��4�4�4�����t�|�4�4�4���K�K�	��T�����+�S�1�1�1���K�K�	��T�����,�c�2�2�2�����t�|�4�4�4���K�K�	��T�����,�c�2�2�2���K�K�	��T�����+�S�1�1�1���K�K�	��T�����,�c�2�2�2�2�2�c�0�tjt��}|D]_\}}|tjkrJ|jdkr?|�|��|�dt|j����n�`|�	d��|D]\}}|tjkrn�|�d|jd��|�|��|�t|��dtj��t|��\}}|�|jd��|�|��t|��t|��\}}|�|jd��|�t��5t|��d	d	d	��n#1swxYwY|���|�|j��|�|j��d	S)
z$Ensure expandItem works as expected.r�z,No "title" element detected in SMALL_SAMPLE!rz=expandNode did not leave DOMEventStream in the correct state.rrrN)rr r!r'r(�
expandNoder%r)�
childNodes�failr"r-�assertRaises�
StopIteration�clear�assertIsNone�parserr)rr0r1�itemr2s     r�test_expandItemzPullDOMTestCase.test_expandItemis6���#�L�1�1���	H�	H�I�C���g�+�+�+����0G�0G�� � ��&�&�&�� � ��C���$8�$8�9�9�9�����I�I�F�G�G�G��	�	�I�C���g�+�+�+���,�����t�|�K�	M�	M�	M�	�����������e���Q���);�<�<�<���K�K�	��T������s�+�+�+�
��������U������K�K�	��T������v�.�.�.�
�
�
�}�
-�
-�	�	���K�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
���
�
�
����%�,�'�'�'����%�,�'�'�'�'�'s�'G�G�
Gc��tjt��}|D]\}}|tjkrdS�|�d��dS)z*PullDOM does not receive "comment" events.zNo comment was encounteredN)rr r!�COMMENTr:)rr0r1�_s    r�test_commentzPullDOMTestCase.test_comment�s[���#�L�1�1���	4�	4�F�C���g�o�%�%����&�
�I�I�2�3�3�3�3�3r5c�4�tjt��}|D]"\}}|tjkr
|jdkrn�#	t|��\}}|�tj|��dS#t$r|�	d��YdSwxYw)z/PullDOM does not receive "end-document" events.rz8Ran out of events, but should have received END_DOCUMENTN)
rr r!r/r(r"r%�END_DOCUMENTr<r:)rr0r1r2s    r�test_end_documentz!PullDOMTestCase.test_end_document�s����#�L�1�1���	�	�I�C���g�)�)�)�d�l�f�.D�.D����	L��U���I�C�����W�1�3�7�7�7�7�7���	L�	L�	L��I�I�J�
L�
L�
L�
L�
L�
L�	L���s�2A4�4B�Bc��tjt��}|j}|�t
��}|�|d��dS)NF)rr r!r?�
getFeaturerr%)rr?�	saxparser�gess    r�test_external_ges_defaultz)PullDOMTestCase.test_external_ges_default�sI���$�\�2�2���M�	��"�"�#7�8�8������e�$�$�$�$�$r5N)�__name__�
__module__�__qualname__rr4rA�unittest�expectedFailurerErHrM�r5rr
r
s�������%�%�%� 93�93�93�|(�(�(�@��4�4���4���
L�
L���
L�%�%�%�%�%r5r
c�F�eZdZdZd�Zejd���Zd�Zdd�Z	dS)	�ThoroughTestCasez(Test the hard-to-reach parts of pulldom.c�p�|�tjdt�������dS)z0Test some of the hard-to-reach parts of PullDOM.N)r?)�_test_thoroughrr
�SAXExerciser�rs r�test_thorough_parsez$ThoroughTestCase.test_thorough_parse�s/�����G�M�$�|�~�~�F�F�F�G�G�G�G�Gr5c�j�tdt��d��}|�|��dS)z2SAX2DOM can"t handle a PI before the root element.N�)�SAX2DOMTestHelperrXrW�r�pds  r�test_sax2dom_failz"ThoroughTestCase.test_sax2dom_fail�s3���t�\�^�^�R�
8�
8�����B�����r5c�l�tdt��d��}|�|d��dS)z0Test some of the hard-to-reach parts of SAX2DOM.Nr\F)r]�SAX2DOMExerciserrWr^s  r�test_thorough_sax2domz&ThoroughTestCase.test_thorough_sax2dom�s6��
�t�%5�%7�%7��
<�
<�����B��&�&�&�&�&r5Tc���t|��\}}|�tj|��|�t|d����|r�t|��\}}|�tj|��|�d|j��t|��\}}|�tj|��|�d|j	��|�d|j��t|��\}}|�tj
|��|�d|j��t|��\}}|�tj|��|�d|j��t|��\}}|�tj|��|�d|j	��|�d|j��t|��\}}|�tj
|��|�d|j��t|��\}}|�tj|��|�d|j��t|��\}}|�tj
|��|�d|j��t|��\}}|�tj
|��|�d|j��t|��\}}|�tj|��dS)	zPTest some of the hard-to-reach parts of the parser, using a mock
        parser.r�	a comment�targetr.rr�textN)r"r%rr&r#r$rCr.�PROCESSING_INSTRUCTIONrfr'r(r-r/rG)rr_�before_rootr1r2s     rrWzThoroughTestCase._test_thorough�s�����H�H�	��T�����/��5�5�5������o�6�6�7�7�7��	0��R���I�C�����W�_�c�2�2�2����[�$�)�4�4�4��R���I�C�����W�;�S�A�A�A����X�t�{�3�3�3����V�T�Y�/�/�/���H�H�	��T�����.��4�4�4�������.�.�.���H�H�	��T������#�.�.�.�����d�i�0�0�0���H�H�	��T�����7��=�=�=�����4�;�/�/�/�������+�+�+���H�H�	��T�����.��4�4�4�����d�l�+�+�+���H�H�	��T�����+�S�1�1�1�������+�+�+���H�H�	��T�����,�c�2�2�2�����d�l�+�+�+���H�H�	��T�����,�c�2�2�2�������.�.�.���H�H�	��T�����-�s�3�3�3�3�3r5N)T)
rNrOrP�__doc__rZrQrRr`rcrWrSr5rrUrU�sn������2�2�H�H�H��� � ��� �
'�'�'�
,4�,4�,4�,4�,4�,4r5rUc�,�eZdZdZd�Zd�Zd�ZeZeZdS)rXznA fake sax parser that calls some of the harder-to-reach sax methods to
    ensure it emits the correct eventsc��||_dS�N)�_handler)rrs  r�setContentHandlerzSAXExerciser.setContentHandler�s
����
�
�
r5c��|j}|���|�d��|�dd��|�dti����|�d��|�dd��|�dtddi����|�d��|�d��|�d��|���dS)	Nrerfr.rr�class�	paraclassrg)	rn�
startDocument�comment�processingInstruction�startElementr�
characters�
endElement�endDocument�rrD�hs   rr
zSAXExerciser.parse�s����M��	������	
�	�	�+����	����&�1�1�1�	���v�~�b�1�1�2�2�2�	�	�	�+����	����&�1�1�1�	���s�N�G�[�+A�B�B�C�C�C�	���V����	���S����	���V����	�
�
�����r5c��dS)zStub method. Does nothing.NrS)r�args�kwargss   r�stubzSAXExerciser.stubs���r5N)	rNrOrPrjror
r�setProperty�
setFeaturerSr5rrXrX�sQ������*�*� � � ����(
�
�
��K��J�J�Jr5rXc��eZdZdZd�ZdS)rbz�The same as SAXExerciser, but without the processing instruction and
    comment before the root element, because S2D can"t handle itc���|j}|���|�dti����|�d��|�dd��|�dtddi����|�d��|�d��|�d��|���dS)	Nrrerfr.rrqrrrg)	rnrsrvrrtrurwrxryrzs   rr
zSAX2DOMExerciser.parses����M��	������	���v�~�b�1�1�2�2�2�	�	�	�+����	����&�1�1�1�	���s�N�G�[�+A�B�B�C�C�C�	���V����	���S����	���V����	�
�
�����r5N)rNrOrPrjr
rSr5rrbrb
s/������D�D�
�
�
�
�
r5rbc��eZdZdZd�ZdS)r]z1Allows us to drive SAX2DOM from a DOMEventStream.c���tj��|_|j�tjjjd��|j�|j��dS)Nr7)	r�SAX2DOMr?r��xml�saxr�feature_namespacesrorYs r�resetzSAX2DOMTestHelper.reset!sN����(�(�������s�w��A�1�E�E�E���%�%�d�l�3�3�3�3�3r5N)rNrOrPrjr�rSr5rr]r]s)������;�;�4�4�4�4�4r5r]c�"�eZdZdd�Zd�Zd�ZdS)�SAX2DOMTestCase�Testc�2�|�||��dSrm)r#)r�test�testnames   r�confirmzSAX2DOMTestCase.confirm*s������h�'�'�'�'�'r5c��tjt��5}t|tj���tt����}|D]"\}}|tj	kr
|j
dkrn�#|�t|j��d��ddd��dS#1swxYwYdS)z'Ensure SAX2DOM can parse from a stream.rrN)
�io�StringIOr!r]r�r��make_parserr)rr'r(�
assertGreaterr9)rr�sdr1r2s     r�
test_basiczSAX2DOMTestCase.test_basic-s���
�[��
&�
&�	8�#�"�3���(;�(;�(=�(=�#&�|�#4�#4�6�6�B��
�
�	��T��'�/�/�/�D�L�F�4J�4J��E��
���s�4�?�3�3�Q�7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s�B
B4�4B8�;B8c���tj��}|���|�di��|�d��|�di��|�d��|�d��|�d��|�d��|���|j}|j}|j	\}}}|j	d}|�
|j��|�|j
|��|�|j|��|�|j
|��|�|j|��|�
|j
��|�
|j��|�
|j
��|�|j|��|�|j|��|�|j|��|�|j|��|�|j|��|���dS)z)Ensure SAX2DOM expands nodes as expected.�docrg�subelmrN)rr�rsrvrwrxry�document�documentElementr9r>�previousSibling�assertIs�nextSibling�
parentNode�unlink)r�sax2domr��root�text1�elm1�text2�text3s        r�testSAX2DOMzSAX2DOMTestCase.testSAX2DOM9s'���/�#�#�����������U�B�'�'�'����6�"�"�"����X�r�*�*�*����6�"�"�"����8�$�$�$����6�"�"�"����5�!�!�!�����������"��#�����e����"�����%�/�0�0�0��
�
�e�'��.�.�.��
�
�d�*�E�2�2�2��
�
�d�&��.�.�.��
�
�e�+�T�2�2�2����%�+�,�,�,����%�/�0�0�0����%�+�,�,�,��
�
�d�o�s�+�+�+��
�
�e�&��-�-�-��
�
�d�o�t�,�,�,��
�
�e�&��-�-�-��
�
�e�&��-�-�-��
�
�����r5N)r�)rNrOrPr�r�r�rSr5rr�r�(sF������(�(�(�(�
8�
8�
8� � � � � r5r��__main__)r�rQ�xml.saxr��xml.sax.xmlreaderr�xml.sax.handlerr�xml.domr�test.supportrrr!�TestCaser
rU�objectrXrb�DOMEventStreamr]r�rN�mainrSr5r�<module>r�s���	�	�	�	���������,�,�,�,�,�,�0�0�0�0�0�0�������!�!�!�!�!�!��(�:�m�
4�
4�
4����N%�N%�N%�N%�N%�h�'�N%�N%�N%�b>4�>4�>4�>4�>4�x�(�>4�>4�>4�B�����6����D�����|����"4�4�4�4�4��.�4�4�4�1�1�1�1�1�h�'�1�1�1�h�z����H�M�O�O�O�O�O��r5