AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_domhelpers.cpython-310.pyc
o

�b+�@srdZddlmZmZddlmZddlmZddlm	Z	m
Z
Gdd�d�ZGdd	�d	ee�ZGd
d�dee�Z
dS)
zH
Specific tests for (some of) the methods in L{twisted.web.domhelpers}.
�)�Any�Optional)�minidom)�TestCase)�
domhelpers�microdomc@s�eZdZUdZdZeeed<dd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�DOMHelpersTestsMixinz�
    A mixin for L{TestCase} subclasses which defines test methods for
    domhelpers functionality based on a DOM creation function provided by a
    subclass.
    N�domcCs�|j�d�}t�|d�dj}d}|�||�|j}t�|d�dj}|�||�d}|j�|�}t�|d�}d�dd�|D��}d}|�||�|j}t�|d�}d�d	d�|D��}|�||�d
}	|j�|	�}
t�|
d�}d�dd�|D��}d}|�||�|
j}t�|d�}d�d
d�|D��}|�||�d}|j�|�}
t�|
d�}|
j}||jdjdg}|�||�t�|d�}|�||�dS)Nz<foo/>�foorz<a><foo in="a"/><b><foo in="b"/></b><c><foo in="c"/></c><foo in="d"/><foo in="ef"/><g><foo in="g"/><h><foo in="h"/></h></g></a>�cS�g|]}|�d��qS��in��getAttribute��.0�node�r�B/usr/lib/python3/dist-packages/twisted/web/test/test_domhelpers.py�
<listcomp>%�zBDOMHelpersTestsMixin.test_getElementsByTagName.<locals>.<listcomp>�abcdefghcSrr
rrrrrr*raH
<a><foo in="a"/>
    <b><foo in="b"/>
        <d><foo in="d"/>
            <g><foo in="g"/></g>
            <h><foo in="h"/></h>
        </d>
        <e><foo in="e"/>
            <i><foo in="i"/></i>
        </e>
    </b>
    <c><foo in="c"/>
        <f><foo in="f"/>
            <j><foo in="j"/></j>
        </f>
    </c>
</a>cSrr
rrrrrr@r�
abdgheicfjcSrr
rrrrrrErz'<foo><bar></bar><baz><foo/></baz></foo>���)	r	�parseStringr�getElementsByTagName�nodeName�assertEqual�documentElement�join�
childNodes)�self�doc1�actual�expected�el1�doc2_xml�doc2�tag_list�el2�doc3_xml�doc3�el3�doc4_xml�doc4�rootrrr�test_getElementsByTagNamesFz.DOMHelpersTestsMixin.test_getElementsByTagNamecCs�|j�d�}t�|�}d}|�||�t�|j�}|�||�d}|j�|�}t�|�}d}|�||�t�|j�}|�||�d}|j�|�}t�|�}d}|�||�t�|j�}|�||�dS)Nz
<a>foo</a>r
z+<a>a<b>b</b><c>c</c>def<g>g<h>h</h></g></a>rzP<a>a<b>b<d>d<g>g</g><h>h</h></d><e>e<i>i</i></e></b><c>c<f>f<j>j</j></f></c></a>r�r	rr�gatherTextNodesrr)r"r#r$r%r'r(r+r,rrr�test_gatherTextNodesQs*

�
z)DOMHelpersTestsMixin.test_gatherTextNodescCs�|j�d�}|j}t�|�|�|��|j�d����|j�d�}|jjd}t�|�|j��}|j�d�}|�	|j�d��|�||���dS)Nz<a><b><c><d/></c></b></a>�ar�b)
r	rrr�	clearNoder�toxml�Elementr!�appendChild)r"r#�a_noder(�b_noder$r%rrr�test_clearNodels


z#DOMHelpersTestsMixin.test_clearNodecCs�|j�d�}|j��}t�|d�}|��}|�d�}|�dd�|�||���t�|d�}|��}|�d�}|�dd�|�||���|�	tj
tj|d�dS)	N�$<a><b id="bar"/><c class="foo"/></a>r
�c�class�barr6�id�pzork)r	r�Documentr�getr8�
createElement�setAttributer�assertRaises�NodeLookupError�r"r#�docrr$r%rrr�test_getzs


zDOMHelpersTestsMixin.test_getcCsl|j�d�}|j��}t�|d�}|��}|�d�}|�dd�|�||���t�|d�}|�	|d�dS)Nr>r
r?r@rC)
r	rrDr�getIfExistsr8rFrGr�assertIdenticalrJrrr�test_getIfExists�s

z%DOMHelpersTestsMixin.test_getIfExistscCsT|j�d�}|j��}t�|d�}|��}|�d�}|�dd�|�||���dS)Nz<a><b id="foo"><c></c></b></a>r
r6rB)	r	rrDr�getAndClearr8rFrGrrJrrr�test_getAndClear�s

z%DOMHelpersTestsMixin.test_getAndClearcCs�|j�d�}|j��}tj|jdddd�}d�dd�|D��}|�d	�}|�dd�|�d
�}|�dd�|�	|�|�
||���tj|jdddd�}d�dd�|D��}|�
||��|���dS)
Nz:<a><b foo="olive"><c foo="olive"/></b><d foo="poopy"/></a>r
�olive�)�	noNestingrcS�g|]}|���qSr�r8rrrrr��z9DOMHelpersTestsMixin.test_locateNodes.<locals>.<listcomp>r6r?rcSrUrrVrrrrr�rW)r	rrDr�locateNodesr!r rFrGr:rr8)r"r#rK�	node_listr$r%r?rrr�test_locateNodes�s�



z%DOMHelpersTestsMixin.test_locateNodescCsL|j�d�}t�|jdjdjd�}d�dd�|D��}|�|d�dS)Nz!<a><b><c><d/></c><e/></b><f/></a>rrcSsg|]
}t|d�r|j�qS��tagName)�hasattrr\rrrrr�sz8DOMHelpersTestsMixin.test_getParents.<locals>.<listcomp>�cba)r	rr�
getParentsr!r r�r"r#rYr$rrr�test_getParents�s��z$DOMHelpersTestsMixin.test_getParentscCsj|j�d�}t�|d�}d�dd�|D��}|�|d�t�|dd�}d�dd�|D��}|�|d	�dS)
Nz+<a foo="1"><b foo="2"/><c foo="1"/><d/></a>r
rcS�g|]}|j�qSrr[rrrrr��zGDOMHelpersTestsMixin.test_findElementsWithAttribute.<locals>.<listcomp>�abc�1cSrbrr[rrrrr�rc�ac)r	rr�findElementsWithAttributer rr`rrr�test_findElementsWithAttribute�sz3DOMHelpersTestsMixin.test_findElementsWithAttributecCs0|j�d�}t�|d�}t|�}|�|d�dS)Nz#<doc><foo/><bar/><foo>a</foo></doc>r
�)r	rr�findNodesNamed�lenrr`rrr�test_findNodesNamed�sz(DOMHelpersTestsMixin.test_findNodesNamedcC�d}d}|�t�|�|�dS)Nz9this string " contains many & characters> xml< won't likezHthis string &quot; contains many &amp; characters&gt; xml&lt; won't like)rr�escape�r"�jr%rrr�test_escape���z DOMHelpersTestsMixin.test_escapecCrm)NzTthis string &quot; has &&amp; entities &gt; &lt; and some characters xml won't like<zEthis string " has && entities > < and some characters xml won't like<)rr�unescaperorrr�
test_unescape�rrz"DOMHelpersTestsMixin.test_unescapecCs"|j�d�}|�t�|�d�dS)z|
        L{getNodeText} returns the concatenation of all the text data at or
        beneath the node passed to it.
        z(<foo><bar>baz</bar><bar>quux</bar></foo>�bazquuxN)r	rrr�getNodeText)r"rrrr�test_getNodeText�sz%DOMHelpersTestsMixin.test_getNodeText)�__name__�
__module__�__qualname__�__doc__r	rr�__annotations__r1r4r=rLrOrQrZrarhrlrqrtrwrrrrrs 
8	

rc@� eZdZeZdd�Zdd�ZdS)�MicroDOMHelpersTestscC�Fd}|j�|�}t�|�}d}|�||�t�|j�}|�||�dS)z�
        Microdom discards whitespace-only text nodes, so L{gatherTextNodes}
        returns only the text from nodes which had non-whitespace characters.
        z?<html>
  <head>
  </head>
  <body>
    stuff
  </body>
</html>
z
    stuff
  Nr2)r"r.r/r$r%rrr�#test_gatherTextNodesDropsWhitespace�s
z8MicroDOMHelpersTests.test_gatherTextNodesDropsWhitespacecCr)zB
        Microdom does not decode entities in text nodes.
        �<x>Souffl&amp;</x>zSouffl&amp;Nr2�r"�doc5_xml�doc5r$r%rrr�test_textEntitiesNotDecoded��
z0MicroDOMHelpersTests.test_textEntitiesNotDecodedN)rxryrzrr	r�r�rrrrr~�sr~c@r})�MiniDOMHelpersTestscCr)z=
        Minidom does decode entities in text nodes.
        r�zSouffl&Nr2r�rrr�test_textEntitiesDecodedr�z,MiniDOMHelpersTests.test_textEntitiesDecodedcCsd|j�d�}t�|�}|�|d�|�|t�|j�d���}t�|�}|�|d�|�|t�dS)z�
        L{domhelpers.getNodeText} returns a C{unicode} string when text
        nodes are represented in the DOM with unicode, whether or not there
        are non-ASCII characters present.
        z<foo>bar</foo>rAu<foo>☃</foo>u☃N)r	rrrvr�assertIsInstance�str�encode)r"r�textrrr�test_getNodeUnicodeTexts

z+MiniDOMHelpersTests.test_getNodeUnicodeTextN)rxryrzrr	r�r�rrrrr�sr�N)r{�typingrr�xml.domr�twisted.trial.unittestr�twisted.webrrrr~r�rrrr�<module>sU$

Anon7 - 2022
AnonSec Team