Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/test/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/test/__pycache__/test_pulldom.cpython-33.pyc

�
��f�0c@s4ddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZeddd�ZdZ
Gd	d
�d
ej�ZGdd�dej�ZGd
d�de�ZGdd�de�ZGdd�dej�ZGdd�dej�Zdd�Zedkr0e�ndS(iN(uAttributesImpl(upulldom(urun_unittestufindfileutest.xmlusubdiruxmltestdatau
<?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>cBsb|EeZdZdd�Zdd�Zdd�Zejdd��Zejd	d
��Z	dS(uPullDOMTestCasec
Cs[tjt�}|j|jj�t|�ttd��}ttj|��WdQXdS(u&Minimal test of DOMEventStream.parse()urbN(upulldomuparseutstfileu
addCleanupustreamucloseulistuopen(uselfuhandlerufin((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyu
test_parses

uPullDOMTestCase.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(u&Test DOMEventStream parsing semantics.u
createElementuhtmliu	xmlns:xdcuhttp://www.xml.com/booksutitleuIntroduction to XSLuhrupu
xdc:authorN(upulldomuparseStringuSMALL_SAMPLEunextu
assertTrueuhasattruassertEqualuSTART_DOCUMENTu
START_ELEMENTutagNameulenu
attributesugetNamedItemuvalueu
CHARACTERSudatauEND_ELEMENT(uselfuitemsuevtunodeu
title_node((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_parse_semantics+sfu$PullDOMTestCase.test_parse_semanticsc	Cs�tjt�}xi|D]T\}}|tjkr|jdkr|j|�|jdt|j��PqqW|j	d�x'|D]\}}|tjkr�Pq�q�W|jd|jd�|j|�|jt
|�dtj�t
|�\}}|j|jd�|j|�t
|�t
|�\}}|j|jd�|jt
��t
|�Wd	QX|j�|j|j�|j|j�d	S(
u$Ensure expandItem works as expected.utitleiu,No "title" element detected in SMALL_SAMPLE!uhru=expandNode did not leave DOMEventStream in the correct state.iupuhtmlN(upulldomuparseStringuSMALL_SAMPLEu
START_ELEMENTutagNameu
expandNodeuassertEqualulenu
childNodesufailunextu
CHARACTERSuassertRaisesu
StopIterationuclearuassertIsNoneuparserustream(uselfuitemsuevtuitemunode((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_expandItemis2





uPullDOMTestCase.test_expandItemcCsJtjt�}x4|D]\}}|tjkrPqqW|jd�dS(u*PullDOM does not receive "comment" events.uNo comment was encounteredN(upulldomuparseStringuSMALL_SAMPLEuCOMMENTufail(uselfuitemsuevtu_((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_comment�s
uPullDOMTestCase.test_commentcCs�tjt�}x6|D].\}}|tjkr|jdkrPqqWy)t|�\}}|jtj|�Wntk
r�|j	d�YnXdS(u/PullDOM does not receive "end-document" events.uhtmlu8Ran out of events, but should have received END_DOCUMENTN(
upulldomuparseStringuSMALL_SAMPLEuEND_ELEMENTutagNameunextuassertEqualuEND_DOCUMENTu
StopIterationufail(uselfuitemsuevtunode((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_end_document�s
u!PullDOMTestCase.test_end_documentN(
u__name__u
__module__u__qualname__u
test_parseutest_parse_semanticsutest_expandItemuunittestuexpectedFailureutest_commentutest_end_document(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuPullDOMTestCases
> 
uPullDOMTestCasecBsV|EeZdZdZdd�Zejdd��Zdd�Zddd	�Z
d
S(uThoroughTestCaseu(Test the hard-to-reach parts of pulldom.cCs#|jtjddt���dS(u0Test some of the hard-to-reach parts of PullDOM.uparserN(u_test_thoroughupulldomuparseuNoneuSAXExerciser(uself((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_thorough_parse�su$ThoroughTestCase.test_thorough_parsecCs&tdt�d�}|j|�dS(u2SAX2DOM can"t handle a PI before the root element.iN(uSAX2DOMTestHelperuNoneuSAXExerciseru_test_thorough(uselfupd((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_sax2dom_fail�su"ThoroughTestCase.test_sax2dom_failcCs)tdt�d�}|j|d�dS(u0Test some of the hard-to-reach parts of SAX2DOM.iNF(uSAX2DOMTestHelperuNoneuSAX2DOMExerciseru_test_thoroughuFalse(uselfupd((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutest_thorough_sax2dom�su&ThoroughTestCase.test_thorough_sax2domcCs�t|�\}}|jtj|�|jt|d��|r�t|�\}}|jtj|�|jd|j�t|�\}}|jtj|�|jd|j	�|jd|j�nt|�\}}|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(	uPTest some of the hard-to-reach parts of the parser, using a mock
        parser.u
createElementu	a commentutargetudatauhtmluputextN(unextuassertEqualupulldomuSTART_DOCUMENTu
assertTrueuhasattruCOMMENTudatauPROCESSING_INSTRUCTIONutargetu
START_ELEMENTutagNameu
CHARACTERSuEND_ELEMENTuEND_DOCUMENT(uselfupdubefore_rootuevtunode((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyu_test_thorough�sFuThoroughTestCase._test_thoroughNT(u__name__u
__module__u__qualname__u__doc__utest_thorough_parseuunittestuexpectedFailureutest_sax2dom_failutest_thorough_sax2domuTrueu_test_thorough(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuThoroughTestCase�s
uThoroughTestCasecBsJ|EeZdZdZdd�Zdd�Zdd�ZeZeZdS(	uSAXExerciserunA fake sax parser that calls some of the harder-to-reach sax methods to
    ensure it emits the correct eventscCs
||_dS(N(u_handler(uselfuhandler((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyusetContentHandler�suSAXExerciser.setContentHandlercCs�|j}|j�|jd�|jdd�|jdti��|jd�|jdd�|jdtidd6��|jd�|jd�|jd�|j�dS(	Nu	a commentutargetudatauhtmlupu	paraclassuclassutext(	u_handleru
startDocumentucommentuprocessingInstructionustartElementuAttributesImplu
charactersu
endElementuendDocument(uselfu_uh((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuparse�s	





uSAXExerciser.parsecOsdS(uStub method. Does nothing.N((uselfuargsukwargs((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyustubsuSAXExerciser.stubN(	u__name__u
__module__u__qualname__u__doc__usetContentHandleruparseustubusetPropertyu
setFeature(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuSAXExerciser�suSAXExercisercBs&|EeZdZdZdd�ZdS(uSAX2DOMExerciseru�The same as SAXExerciser, but without the processing instruction and
    comment before the root element, because S2D can"t handle itcCs�|j}|j�|jdti��|jd�|jdd�|jdtidd6��|jd�|jd�|jd�|j�dS(	Nuhtmlu	a commentutargetudataupu	paraclassuclassutext(	u_handleru
startDocumentustartElementuAttributesImplucommentuprocessingInstructionu
charactersu
endElementuendDocument(uselfu_uh((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuparses	




uSAX2DOMExerciser.parseN(u__name__u
__module__u__qualname__u__doc__uparse(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuSAX2DOMExercisersuSAX2DOMExercisercBs&|EeZdZdZdd�ZdS(uSAX2DOMTestHelperu1Allows us to drive SAX2DOM from a DOMEventStream.cCsBtj�|_|jjtjjjd�|jj|j�dS(Ni(	upulldomuSAX2DOMuparseru
setFeatureuxmlusaxuhandlerufeature_namespacesusetContentHandler(uself((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuresetsuSAX2DOMTestHelper.resetN(u__name__u
__module__u__qualname__u__doc__ureset(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuSAX2DOMTestHelpersuSAX2DOMTestHelpercBs;|EeZdZddd�Zdd�Zdd�ZdS(	uSAX2DOMTestCaseuTestcCs|j||�dS(N(u
assertTrue(uselfutestutestname((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuconfirm$suSAX2DOMTestCase.confirmcCs�tjt��z}t|tjj�tt��}x6|D].\}}|tj	kr:|j
dkr:Pq:q:W|jt|j�d�WdQXdS(u'Ensure SAX2DOM can parse from a stream.uhtmliN(
uiouStringIOuSMALL_SAMPLEuSAX2DOMTestHelperuxmlusaxumake_parserulenupulldomu
START_ELEMENTutagNameu
assertGreateru
childNodes(uselfufinusduevtunode((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyu
test_basic'suSAX2DOMTestCase.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(u)Ensure SAX2DOM expands nodes as expected.udocutextusubelmiN(upulldomuSAX2DOMu
startDocumentustartElementu
charactersu
endElementuendDocumentudocumentudocumentElementu
childNodesuassertIsNoneupreviousSiblinguassertIsunextSiblingu
parentNodeuunlink(uselfusax2domudocurootutext1uelm1utext2utext3((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyutestSAX2DOM3s8






		
uSAX2DOMTestCase.testSAX2DOMN(u__name__u
__module__u__qualname__uconfirmu
test_basicutestSAX2DOM(u
__locals__((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyuSAX2DOMTestCase"suSAX2DOMTestCasecCstttt�dS(N(urun_unittestuPullDOMTestCaseuThoroughTestCaseuSAX2DOMTestCase(((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyu	test_mainVsu	test_mainu__main__(uiouunittestusysuxml.saxuxmluxml.sax.xmlreaderuAttributesImpluxml.domupulldomutest.supporturun_unittestufindfileutstfileuSMALL_SAMPLEuTestCaseuPullDOMTestCaseuThoroughTestCaseuobjectuSAXExerciseruSAX2DOMExerciseruDOMEventStreamuSAX2DOMTestHelperuSAX2DOMTestCaseu	test_mainu__name__(((u6/opt/alt/python33/lib64/python3.3/test/test_pulldom.pyu<module>s"
�A"
4