https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/genshi/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/genshi/tests/__pycache__/path.cpython-310.pyc
o

!�b�k�@s�ddlZddlmZmZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZGdd�de�ZGdd	�d	ej�Zd
d�ZedkrIejdd
�dSdS)�N)�Attrs�QName)�XML)�Path�
PathParser�PathSyntaxError�GenericStrategy�SingleStepStrategy�SimplePathStrategy)�
doctest_suitec@seZdZdd�Zddd�ZdS)�FakePathcCs
||_dS�N)�strategy)�selfr�r�3/usr/lib/python3/dist-packages/genshi/tests/path.py�__init__s
zFakePath.__init__FcCs|j�|�Sr
)r�test)r�ignore_contextrrrrsz
FakePath.testN)F)�__name__�
__module__�__qualname__rrrrrrrsrc@s(eZdZeeegZdd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*dIdJ�Z+dKdL�Z,dMdN�Z-dOdP�Z.dQdR�Z/dSdT�Z0dUdV�Z1dWdX�Z2dYdZ�Z3d[d\�Z4d]d^�Z5d_d`�Z6dadb�Z7dcdd�Z8dedf�Z9dgdh�Z:didj�Z;dkdl�Z<dmdn�Z=dodp�Z>dqdr�Z?dsdt�Z@dudv�ZAdwdx�ZBdydz�ZCd{d|�ZDd}d~�ZE	d�d�d��ZF	�	d�d�d��ZGdS)��PathTestCasecCs|�ttd�dS)Nz/root��assertRaisesrr�rrrr�test_error_no_absolute_path"sz(PathTestCase.test_error_no_absolute_pathcCs |�ttd�|�ttd�dS)Nz..z
parent::marrrrr�test_error_unsupported_axis%sz(PathTestCase.test_error_unsupported_axiscCsftd�}|jdd|dd�|jdd|dd�|jdd|dd�|jdd|dd�|jd	d
|dd�dS)N�<root><elem/></root>�elemz<Path "child::elem">�<elem/>��path�equiv�input�outputzchild::elemz//elemz!<Path "descendant-or-self::elem">zdescendant::elemz<Path "descendant::elem">�r�
_test_eval�r�xmlrrr�
test_1step)s>����
�zPathTestCase.test_1stepcCs0td�}|jdd|dd�|jdd|dd�dS)Nr�.z<Path "self::node()">r!zself::node()r&r(rrr�test_1step_selfJ��
�zPathTestCase.test_1step_selfcCsTtd�}|jdd|dd�|jdd|dd�|jdd|dd�|jd	d
|dd�dS)Nr�*z<Path "child::*">r r!zchild::*z
child::node()�<Path "child::node()">z//*z<Path "descendant-or-self::*">r&r(rrr�test_1step_wildcardY�2���
�z PathTestCase.test_1step_wildcardcCsF|jddtd�dd�td�}|jdd|dd�|jdd	|dd�dS)
Nz@fooz<Path "attribute::foo">z<root/>�r!z<root foo="bar"/>�barz./@fooz$<Path "self::node()/attribute::foo">�r'rr(rrr�test_1step_attributets&��
�z!PathTestCase.test_1step_attributecCsTtd�}|jdd|dd�|jdd|dd�|jdd	|dd�|jd
d|dd�dS)Nz<root>Hey</root>�text()�<Path "child::text()">�Heyr!�./text()�#<Path "self::node()/child::text()">�//text()�#<Path "descendant-or-self::text()">z	.//text()z><Path "self::node()/descendant-or-self::node()/child::text()">r&r(rrr�test_1step_text�r1zPathTestCase.test_1step_textcCs<td�}|jd|dd�|jd|dd�|jd|dd�dS)	N�<root><foo/><bar/></root>r.z<foo/><bar/>�r$r%r3�<bar/>�bazr2r&r(rrr�
test_2step�szPathTestCase.test_2stepcCsttd�}|jd|dd�|jd|dd�|jd|dd�|jd|d	d�td
�}|jd|dd�|jd|d
d�dS)Nz4<elem class="x"><span id="joe">Hey Joe</span></elem>z@*�xr?z./@*z.//@*�xjoez*/@*�joez'<elem><foo id="1"/><foo id="2"/></elem>r2zfoo/@*�12r&r(rrr�test_2step_attribute�sz!PathTestCase.test_2step_attributecCs�td�}|jdd|dd�|jdd|dd�|jd	d
|dd�td�}|jdd|dd�td
�}|jd|dd�td�}|jd|dd�dS)N�<root><foo><bar/></foo></root>zfoo/barz<Path "child::foo/child::bar">r@r!z./barz <Path "self::node()/child::bar">r2�foo/*�<Path "child::foo/child::*">�2<root><foo><bar id="1"/></foo><bar id="2"/></root>z
<bar id="2"/>zp<table>
            <tr><td>1</td><td>One</td></tr>
            <tr><td>2</td><td>Two</td></tr>
        </table>ztr/td[1]z<td>1</td><td>2</td>)r"r$r%z�<ul>
            <li>item1
                <ul><li>subitem11</li></ul>
            </li>
            <li>item2
                <ul><li>subitem21</li></ul>
            </li>
        </ul>zli[2]/ulz<ul><li>subitem21</li></ul>r&r(rrr�test_2step_complex�sL�����
�zPathTestCase.test_2step_complexcCs�td�}|jdd|dd�|jdd|dd�|jdd	|dd�|jd
d|dd�td
�}|jdd|dd�td�}|jdd|dd�dS)Nz<root><item>Foo</item></root>zitem/text()z"<Path "child::item/child::text()">�Foor!z*/text()z<Path "child::*/child::text()">r;r<r9r:r2z-<root><item>Foo</item><item>Bar</item></root>�FooBarzE<root><item><name>Foo</name><sub><name>Bar</name></sub></item></root>zitem/name/text()z.<Path "child::item/child::name/child::text()">r&r(rrr�test_2step_text�sN�����
�zPathTestCase.test_2step_textcC�td�}|jdd|dd�dS)NrHrIrJr@r!r&r(rrr�
test_3step�
�zPathTestCase.test_3stepcCs0|jddtd�dd�|jddtd�d	d�dS)
Nz*/barz<Path "child::*/child::bar">rHr@r!z//barz <Path "descendant-or-self::bar">rKz<bar id="1"/><bar id="2"/>r4rrrr�test_3step_complexs�
�zPathTestCase.test_3step_complexcCs0td�}|jdd|dd�|jdd|dd�dS)	NzM<root><item><bar>Some text </bar><baz><bar>in here.</bar></baz></item></root>zitem/bar/text()z-<Path "child::item/child::bar/child::text()">z
Some text r!zitem//bar/text()zH<Path "child::item/descendant-or-self::node()/child::bar/child::text()">�Some text in here.r&r(rrr�test_3step_complex_text'r-z$PathTestCase.test_3step_complex_textcCrP)Nz<root><!-- commented --></root>z	comment()z<Path "child::comment()">z<!-- commented -->r!r&r(rrr�test_node_type_comment6rRz#PathTestCase.test_node_type_commentcCrP)N�$<root>Some text <br/>in here.</root>r6r7rTr!r&r(rrr�test_node_type_text?rRz PathTestCase.test_node_type_textcCrP)NrWznode()r/zSome text <br/>in here.r!r&r(rrr�test_node_type_nodeHrRz PathTestCase.test_node_type_nodecCsBtd�}|jdd|dd�|jdd|dd�|jd	d
|dd�dS)Nz4<?python x = 2 * 3 ?><root><?php echo("x") ?></root>z//processing-instruction()z5<Path "descendant-or-self::processing-instruction()">z'<?python x = 2 * 3 ?><?php echo("x") ?>r!zprocessing-instruction()z(<Path "child::processing-instruction()">z<?php echo("x") ?>zprocessing-instruction("php")z-<Path "child::processing-instruction("php")">r&r(rrr�%test_node_type_processing_instructionQs&��
�z2PathTestCase.test_node_type_processing_instructioncCrP)Nz"<body>1<br />2<br />3<br /></body>z*|text()z<Path "child::*|child::text()">z1<br/>2<br/>3<br/>r!r&r(rrr�test_simple_unionfrRzPathTestCase.test_simple_unioncC�td�}|jd|dd�dS)Nr>z*[name()="foo"]�<foo/>r?r&r(rrr�test_predicate_nameo�z PathTestCase.test_predicate_namecCr\)N�$<root><foo xmlns="NS"/><bar/></root>z*[local-name()="foo"]�<foo xmlns="NS"/>r?r&r(rrr�test_predicate_localnames�
�z%PathTestCase.test_predicate_localnamecCr\)Nr`z*[namespace-uri()="NS"]rar?r&r(rrr�test_predicate_namespacexrcz%PathTestCase.test_predicate_namespacecCr\)Nr>z*[not(name()="foo")]r@r?r&r(rrr�test_predicate_not_name}rcz$PathTestCase.test_predicate_not_namecC�,td�}|jd|dd�|jd|dd�dS)N�,<root><item/><item important="very"/></root>zitem[@important]�<item important="very"/>r?�item[@important="very"]r&r(rrr�test_predicate_attr���
�z PathTestCase.test_predicate_attrcC�,td�}|jd|dd�|jd|dd�dS)Nz-<root><item/><item important="notso"/></root>rir2r?zitem[@important!="very"]z <item/><item important="notso"/>r&r(rrr�test_predicate_attr_equality��

�z)PathTestCase.test_predicate_attr_equalitycCrl)N�!<root><item priority="3"/></root>zitem[@priority>3]r2r?zitem[@priority>2]�<item priority="3"/>r&r(rrr� test_predicate_attr_greater_than�rnz-PathTestCase.test_predicate_attr_greater_thancCrl)Nrozitem[@priority<3]r2r?zitem[@priority<4]rpr&r(rrr�test_predicate_attr_less_than�rnz*PathTestCase.test_predicate_attr_less_thancCrl)Nrgz&item[@important and @important="very"]rhr?z'item[@important and @important="notso"]r2r&r(rrr�test_predicate_attr_and�s�
�z$PathTestCase.test_predicate_attr_andcCrl)Nrgzitem[@urgent or @important]rhr?zitem[@urgent or @notso]r2r&r(rrr�test_predicate_attr_or�s
�z#PathTestCase.test_predicate_attr_orcCsltd�}|jd|dd�|jd|dd�|jd|dd�|jd|dd�|jd	|dd�|jd
|dd�dS)N�<root><foo>bar</foo></root>z*[boolean("")]r2r?z*[boolean("yo")]�<foo>bar</foo>z
*[boolean(0)]z*[boolean(42)]z*[boolean(false())]z*[boolean(true())]r&r(rrr�test_predicate_boolean_function�s��
�z,PathTestCase.test_predicate_boolean_functioncCr\)Nruz*[ceiling("4.5")=5]rvr?r&r(rrr�test_predicate_ceil_function�rcz)PathTestCase.test_predicate_ceil_functioncCr\)Nruz*[name()=concat("f", "oo")]rvr?r&r(rrr�test_predicate_concat_function�rcz+PathTestCase.test_predicate_concat_functioncCr\)Nruz*[contains(name(), "oo")]rvr?r&r(rrr� test_predicate_contains_function�rcz-PathTestCase.test_predicate_contains_functioncCr\)Nz)<root><foo>bar</foo><bar>foo</bar></root>z*[matches(name(), "foo|bar")]z<foo>bar</foo><bar>foo</bar>r?r&r(rrr�test_predicate_matches_function�rcz,PathTestCase.test_predicate_matches_functioncCr\)Nruz
*[false()]r2r?r&r(rrr�test_predicate_false_function�r_z*PathTestCase.test_predicate_false_functioncCr\)Nruz*[floor("4.5")=4]rvr?r&r(rrr�test_predicate_floor_function�rcz*PathTestCase.test_predicate_floor_functioncCr\)Nruz,*[normalize-space(" foo   bar  ")="foo bar"]rvr?r&r(rrr�'test_predicate_normalize_space_function��
�z4PathTestCase.test_predicate_normalize_space_functioncCs<td�}|jd|dd�|jd|dd�|jd|dd�dS)Nruz*[number("3.0")=3]rvr?z*[number("3.0")=3.0]z*[number("0.1")=.1]r&r(rrr�test_predicate_number_function�s��
�z+PathTestCase.test_predicate_number_functioncCrf)Nruz*[round("4.4")=4]rvr?z*[round("4.6")=5]r&r(rrr�test_predicate_round_function�rkz*PathTestCase.test_predicate_round_functioncCrl)Nruz*[starts-with(name(), "f")]rvr?z*[starts-with(name(), "b")]r2r&r(rrr�#test_predicate_starts_with_function�rkz0PathTestCase.test_predicate_starts_with_functioncCr\)Nruz*[string-length(name())=3]rvr?r&r(rrr�%test_predicate_string_length_function�rcz2PathTestCase.test_predicate_string_length_functioncCrf)Nruz*[substring(name(), 1)="oo"]rvr?z*[substring(name(), 1, 1)="o"]r&r(rrr�!test_predicate_substring_function�rkz.PathTestCase.test_predicate_substring_functioncCr\)Nruz$*[substring-after(name(), "f")="oo"]rvr?r&r(rrr�'test_predicate_substring_after_function�rcz4PathTestCase.test_predicate_substring_after_functioncCr\)Nruz%*[substring-before(name(), "oo")="f"]rvr?r&r(rrr�(test_predicate_substring_before_function�rz5PathTestCase.test_predicate_substring_before_functioncCr\)Nruz&*[translate(name(), "fo", "ba")="baa"]rvr?r&r(rrr�!test_predicate_translate_functionrz.PathTestCase.test_predicate_translate_functioncCr\)Nruz	*[true()]rvr?r&r(rrr�test_predicate_true_functionr_z)PathTestCase.test_predicate_true_functioncC�"td�}|jd|dddid�dS)Nruz*[name()=$bar]rvr3�foo)r"r$r%�	variablesr&r(rrr�test_predicate_variables
�z$PathTestCase.test_predicate_variablecCr\)Nz7<root><foo id="a1"/><foo id="a2"/><foo id="a3"/></root>z*[2]�<foo id="a2"/>r?r&r(rrr�test_predicate_positionr_z$PathTestCase.test_predicate_positioncCr\)N�/<root><foo/><foo id="a1"/><foo id="a2"/></root>z	*[@id][2]r�r?r&r(rrr� test_predicate_attr_and_positionr_z-PathTestCase.test_predicate_attr_and_positioncCrl)Nr�z	*[1][@id]r2r?z	*[2][@id]z<foo id="a1"/>r&r(rrr� test_predicate_position_and_attrsz-PathTestCase.test_predicate_position_and_attrcCr\)Nz-<root><a><b><c><d><e/></d></c></b></a></root>z]descendant-or-self::*/descendant-or-self::*/descendant-or-self::*[2]/self::*/descendant::*[3]z<d><e/></d>r?r&r(rrr� test_predicate_advanced_position"s

�z-PathTestCase.test_predicate_advanced_positioncCrl)NzC<root><a><b>1</b><b>2</b><b>3</b></a><a><b>4</b><b>5</b></a></root>z//a/b[2]z<b>2</b><b>5</b>r?z//a/b[3]z<b>3</b>r&r(rrr�test_predicate_child_position*sz*PathTestCase.test_predicate_child_positioncC�$td�}|jdd|dddid�dS)N�-<root xmlns:f="FOO"><f:foo>bar</f:foo></root>zf:fooz<Path "child::f:foo">�<foo xmlns="FOO">bar</foo>�f�FOO�r"r#r$r%�
namespacesr&r(rrr�test_name_with_namespace0�
�z%PathTestCase.test_name_with_namespacecCr�)Nr�zf:*z<Path "child::f:*">r�r�r�r�r&r(rrr�test_wildcard_with_namespace:r�z)PathTestCase.test_wildcard_with_namespacecCs4td�}|jd|dd�td�}|jd|dd�dS)z�
        Verify that a patch matching the self axis with a predicate doesn't
        cause an infinite loop. See <http://genshi.edgewall.org/ticket/82>.
        z&<ul flag="1"><li>a</li><li>b</li></ul>z.[@flag="1"]/*z<li>a</li><li>b</li>r?z.[@flag="0"]/*r2Nr&r(rrr�test_predicate_terminationDs�z'PathTestCase.test_predicate_terminationcCr�)N�-<root xmlns:f="FOO"><foo f:bar="baz"/></root>zfoo[@f:bar]�$<foo xmlns:ns1="FOO" ns1:bar="baz"/>r�r��r$r%r�r&r(rrr�test_attrname_with_namespaceP�

�z)PathTestCase.test_attrname_with_namespacecCr�)Nr�z	foo[@f:*]r�r�r�r�r&r(rrr� test_attrwildcard_with_namespaceVr�z-PathTestCase.test_attrwildcard_with_namespacecCsltd�}|jd|dd�|jd|dd�|jd|dd�|jd|dd�|jd	|dd�|jd
|dd�dS)Nz<root><foo/></root>z
self::rootr?z	self::foor2zdescendant::rootzdescendant::foor]zdescendant-or-self::rootzdescendant-or-self::foor&r(rrr�test_self_and_descendant\s�z%PathTestCase.test_self_and_descendantcCs�td�}|jd|dd�|jd|dd�|jd|dd�|jd|dd�|jd|dd�|jd	|dd�|jd
|dd�|jd|dd�|jd
|dd�dS)Nzb<root><a><b><a><d><a><b><a><b><a><b><a><c>!</c></a></b></a></b></a></b></a></d></a></b></a></root>z
//a/b/a/b/a/cz<c>!</c>r?z	//a/b/a/cz//a/cz//cza/b/descendant::a/cz#a/b/descendant::a/d/descendant::a/cza/b/descendant::a/d/a/cr2z;//d/descendant::b/descendant::b/descendant::b/descendant::czI//d/descendant::b/descendant::b/descendant::b/descendant::b/descendant::cr&r(rrr�test_long_simple_pathsfs"��
�z#PathTestCase.test_long_simple_pathscCs>td�}td�}|�|�}|�t|�ttd�dfg�g�dS)Nz"<root><foo bar="abc"></foo></root>zfoo/@barr3�abc�rr�select�assertEqual�listrr�rr)r"�resultrrr�test_attr_selectionzs


�z PathTestCase.test_attr_selectioncCsFtd�}td�}|j|ddid�}|�t|�ttd�dfg�g�dS)NzE<root xmlns:ns1="http://example.com"><foo ns1:bar="abc"></foo></root>zfoo/@ns1:bar�ns1zhttp://example.com)r�zhttp://example.com}barr�r�r�rrr�"test_attr_selection_with_namespace�s�

�z/PathTestCase.test_attr_selection_with_namespacecCst|dd���d}|�|�S)N���r)r�parse�supports)r�strategy_class�textr"rrr�
_test_support�s
zPathTestCase._test_supportcCs�|�|�td��|�|�td��|�|�td��|�|�td��|�|�td��|�|�td��|�|�td��|�|�td��|�|�td	��|�|�td
��|�|�td��|�|�td��dS)
Nza/bz	self::a/bzdescendant::a/bzdescendant-or-self::a/bz//a/bza/@bza/text()za//bz	node()/@az@azfoo:barz
a/@foo:bar)�
assertTruer�r
rrrr�test_simple_strategy_support�s
�z)PathTestCase.test_simple_strategy_supportNc
Csr|jD]3}|�|�sq||�}t|�j|||d�jdd�}dt|�}	|	d|7}	|	d|7}	|�|||	�qdS)N�r�r���encodingzBad render using %s strategy�
Expected:	%r�
Rendered:	%r)�
strategiesr�rr��render�strr�)
rr$r"r%r�r�r�s�rendered�msgrrr�_test_strategies�s

���zPathTestCase._test_strategiesr2c	Cs�t|�}|dur|�|t|��|durdS|j|||d�jdd�}d}|d|7}|d|7}|�|||�t|j�dkrM|j||jd|||d�dSdS)Nr�r�zBad output using whole pathr�r��r)rr��reprr�r��len�pathsr�)	rr"r#r$r%r�r�r�r�rrrr'�s&��
��zPathTestCase._test_eval)NN)NNr2NN)Hrrrrr	r
r�rrr*r,r0r5r=rBrGrLrOrQrSrUrVrXrYrZr[r^rbrdrerjrmrqrrrsrtrwrxryrzr{r|r}r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r'rrrrrs�
!2)							



��rcCs.t��}|�ttj��|�t�td��|S)Nr)�unittest�	TestSuite�addTestrrr�	makeSuiter)�suiterrrr��sr��__main__)�defaultTest)r��genshi.corerr�genshi.inputr�genshi.pathrrrrr	r
�genshi.tests.test_utilsrr�TestCaserr�r�mainrrrr�<module>s 
 ,�

https://t.me/RX1948 - 2025