Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_pulldom.cpython-35.opt-2.pyc



���]Q0�@s"ddlZddlZddlZddlZddlmZddlmZddl	m
Z
e
ddd�ZdZGd	d
�d
ej
�ZGdd�dej
�ZGd
d�de�ZGdd�de�ZGdd�dej�ZGdd�dej
�Zedkrej�dS)�N)�AttributesImpl)�pulldom)�findfileztest.xmlZsubdirZxmltestdataa
<?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@s^eZdZdd�Zdd�Zdd�Zejdd��Zejd	d
��Z	dS)�PullDOMTestCasec
Cs\tjt�}|j|jj�t|�ttd��}ttj|��WdQRXdS)N�rb)r�parse�tstfileZ
addCleanup�stream�close�list�open)�self�handler�fin�r�1/opt/alt/python35/lib64/python3.5/test_pulldom.py�
test_parses

zPullDOMTestCase.test_parsecCs�tjt�}t|�\}}|jt|d��|jtj|�t|�\}}|jtj|�|jd|j	�|jdt
|j��|j|jjd�j
d�t|�\}}|jtj|�t|�\}}|jtj|�t|�\}}|jd|j	�|}t|�\}}|jtj|�|jd|j�t|�\}}|jtj|�|jd|j	�|j||k�t|�\}}|jtj|�t|�\}}|jtj|�|jd|j	�t|�\}}|jtj|�|jd|j	�t|�\}}|jtj|�t|�\}}|jtj|�|jd	|j	�t|�\}}|jtj|�|jd
|j	�t|�\}}|jtj|�t|�\}}|jtj|�|jd
|j	�t|�\}}|jtj|�t|�\}}|jtj|�t|�\}}|jtj|�dS)N�
createElement�html�z	xmlns:xdczhttp://www.xml.com/books�titlezIntroduction to XSL�hr�pz
xdc:author)r�parseString�SMALL_SAMPLE�next�
assertTrue�hasattr�assertEqual�START_DOCUMENT�
START_ELEMENT�tagName�lenZ
attributesZgetNamedItem�value�
CHARACTERS�data�END_ELEMENT)r
�items�evt�nodeZ
title_noderrr�test_parse_semantics+sfz$PullDOMTestCase.test_parse_semanticsc	Cs�tjt�}xf|D]Q\}}|tjkr|jdkr|j|�|jdt|j��PqW|j	d�x$|D]\}}|tjkrPqW|jd|jd�|j|�|jt
|�dtj�t
|�\}}|j|jd�|j|�t
|�t
|�\}}|j|jd�|jt
��t
|�WdQRX|j�|j|j�|j|j�dS)	Nr�z,No "title" element detected in SMALL_SAMPLE!rz=expandNode did not leave DOMEventStream in the correct state.rrr)rrrr r!Z
expandNoderr"�
childNodes�failrr$ZassertRaises�
StopIteration�clear�assertIsNone�parserr	)r
r'r(�itemr)rrr�test_expandItemis2





zPullDOMTestCase.test_expandItemcCsGtjt�}x1|D]\}}|tjkrPqW|jd�dS)NzNo comment was encountered)rrr�COMMENTr-)r
r'r(�_rrr�test_comment�s
zPullDOMTestCase.test_commentcCs�tjt�}x3|D]+\}}|tjkr|jdkrPqWy)t|�\}}|jtj|�Wntk
r�|j	d�YnXdS)Nrz8Ran out of events, but should have received END_DOCUMENT)
rrrr&r!rr�END_DOCUMENTr.r-)r
r'r(r)rrr�test_end_document�s
z!PullDOMTestCase.test_end_documentN)
�__name__�
__module__�__qualname__rr*r3�unittest�expectedFailurer6r8rrrrrs
> 
rc@sLeZdZdd�Zejdd��Zdd�Zddd	�Zd
S)�ThoroughTestCasecCs#|jtjddt���dS)Nr1)�_test_thoroughrr�SAXExerciser)r
rrr�test_thorough_parse�sz$ThoroughTestCase.test_thorough_parsecCs&tdt�d�}|j|�dS)N�)�SAX2DOMTestHelperr@r?)r
�pdrrr�test_sax2dom_fail�sz"ThoroughTestCase.test_sax2dom_failcCs)tdt�d�}|j|d�dS)NrBF)rC�SAX2DOMExerciserr?)r
rDrrr�test_thorough_sax2dom�sz&ThoroughTestCase.test_thorough_sax2domTcCs�t|�\}}|jtj|�|jt|d��|r�t|�\}}|jtj|�|jd|j�t|�\}}|jtj|�|jd|j	�|jd|j�t|�\}}|jtj
|�|jd|j�t|�\}}|jtj|�|jd|j�t|�\}}|jtj|�|jd|j	�|jd|j�t|�\}}|jtj
|�|jd|j�t|�\}}|jtj|�|jd|j�t|�\}}|jtj
|�|jd|j�t|�\}}|jtj
|�|jd|j�t|�\}}|jtj|�dS)Nrz	a comment�targetr%rr�text)rrrrrrr4r%ZPROCESSING_INSTRUCTIONrHr r!r$r&r7)r
rDZbefore_rootr(r)rrrr?�sFzThoroughTestCase._test_thoroughN)	r9r:r;rAr<r=rErGr?rrrrr>�sr>c@s@eZdZdd�Zdd�Zdd�ZeZeZdS)r@cCs
||_dS)N)�_handler)r
rrrr�setContentHandler�szSAXExerciser.setContentHandlercCs�|j}|j�|jd�|jdd�|jdti��|jd�|jdd�|jdtddi��|jd�|jd�|jd�|j�dS)	Nz	a commentrHr%rr�class�	paraclassrI)	rJ�
startDocument�comment�processingInstruction�startElementr�
characters�
endElement�endDocument)r
r5�hrrrr�s	





zSAXExerciser.parsecOsdS)Nr)r
�args�kwargsrrr�stubszSAXExerciser.stubN)r9r:r;rKrrXZsetProperty�
setFeaturerrrrr@�s
r@c@seZdZdd�ZdS)rFcCs�|j}|j�|jdti��|jd�|jdd�|jdtddi��|jd�|jd�|jd�|j�dS)	Nrz	a commentrHr%rrLrMrI)	rJrNrQrrOrPrRrSrT)r
r5rUrrrrs	




zSAX2DOMExerciser.parseN)r9r:r;rrrrrrFsrFc@seZdZdd�ZdS)rCcCsBtj�|_|jjtjjjd�|jj|j�dS)Nr+)	r�SAX2DOMr1rY�xml�saxrZfeature_namespacesrK)r
rrr�resetszSAX2DOMTestHelper.resetN)r9r:r;r]rrrrrCsrCc@s7eZdZddd�Zdd�Zdd�ZdS)	�SAX2DOMTestCaseZTestcCs|j||�dS)N)r)r
ZtestZtestnamerrr�confirm$szSAX2DOMTestCase.confirmcCs�tjt��w}t|tjj�tt��}x3|D]+\}}|tj	kr:|j
dkr:Pq:W|jt|j�d�WdQRXdS)Nrr)
�io�StringIOrrCr[r\Zmake_parserr"rr r!Z
assertGreaterr,)r
r�sdr(r)rrr�
test_basic'szSAX2DOMTestCase.test_basiccCs�tj�}|j�|jdi�|jd�|jdi�|jd�|jd�|jd�|jd�|j�|j}|j}|j	\}}}|j	d}|j
|j�|j|j
|�|j|j|�|j|j
|�|j|j|�|j
|j
�|j
|j�|j
|j
�|j|j|�|j|j|�|j|j|�|j|j|�|j|j|�|j�dS)N�docrIZsubelmr)rrZrNrQrRrSrTZdocumentZdocumentElementr,r0ZpreviousSiblingZassertIsZnextSiblingZ
parentNode�unlink)r
Zsax2domrd�rootZtext1Zelm1Ztext2Ztext3rrr�testSAX2DOM3s8






		
zSAX2DOMTestCase.testSAX2DOMN)r9r:r;r_rcrgrrrrr^"sr^�__main__)r`r<�sysZxml.saxr[Zxml.sax.xmlreaderrZxml.domrZtest.supportrrrZTestCaserr>�objectr@rFZDOMEventStreamrCr^r9�mainrrrr�<module>s 
�A"
4