HEX
Server: Apache
System: Linux pdx1-shared-a1-29 6.18.39-grsec-noble+ #4 SMP Thu Jul 23 07:53:29 UTC 2026 x86_64
User: dh_bj99yp (22285841)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/genshi/template/tests/__pycache__/directives.cpython-312.pyc
�

EMab(���(�ddlZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZGd�dej�Z
Gd�dej�ZGd�d	ej�ZGd
�dej�ZGd�d
ej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�Zd�Zedk(rej2d��yy)�N)�
IS_PYTHON2)�
directives�MarkupTemplate�TextTemplate�TemplateRuntimeError�TemplateSyntaxErrorc�"�eZdZdZd�Zd�Zd�Zy)�AttrsDirectiveTestCasez,Tests for the `py:attrs` template directive.c��td�}ddiddig}|jd|j|��jd���y)	zM
        Verify that the directive has access to the loop variables.
        zt<doc xmlns:py="http://genshi.edgewall.org/">
          <elem py:for="item in items" py:attrs="item"/>
        </doc>�id��z;<doc>
          <elem id="1"/><elem id="2"/>
        </doc>��itemsN��encoding�r�assertEqual�generate�render)�self�tmplrs   �B/usr/lib/python3/dist-packages/genshi/template/tests/directives.py�test_combined_with_loopz.AttrsDirectiveTestCase.test_combined_with_loopsW���������T�1�I�&�������=�=�u�=�-�4�4�d�4�C�	E�c�z�td�}|jd|j�jd���y)�}
        Verify that an attribute value that evaluates to `None` removes an
        existing attribute of that name.
        zu<doc xmlns:py="http://genshi.edgewall.org/">
          <elem class="foo" py:attrs="{'class': 'bar'}"/>
        </doc>z2<doc>
          <elem class="bar"/>
        </doc>Nrr�rrs  r�test_update_existing_attrz0AttrsDirectiveTestCase.test_update_existing_attr'�?��
����	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)rzt<doc xmlns:py="http://genshi.edgewall.org/">
          <elem class="foo" py:attrs="{'class': None}"/>
        </doc>z&<doc>
          <elem/>
        </doc>Nrrrs  r�test_remove_existing_attrz0AttrsDirectiveTestCase.test_remove_existing_attr3r rN)�__name__�
__module__�__qualname__�__doc__rrr"�rrr
r
s��6�
E�
:�
:rr
c�^�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�ChooseDirectiveTestCasezoTests for the `py:choose` template directive and the complementary
    directives `py:when` and `py:otherwise`.c�z�td�}|jd|j�jd���y)zd
        Verify that, if multiple `py:when` bodies match, only the first is
        output.
        z�<div xmlns:py="http://genshi.edgewall.org/" py:choose="">
          <span py:when="1 == 1">1</span>
          <span py:when="2 == 2">2</span>
          <span py:when="3 == 3">3</span>
        </div>z-<div>
          <span>1</span>
        </div>Nrrrs  r�test_multiple_true_whensz0ChooseDirectiveTestCase.test_multiple_true_whensD�?��
����
	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/" py:choose="">
          <span py:when="False">hidden</span>
          <span py:otherwise="">hello</span>
        </div>z1<div>
          <span>hello</span>
        </div>rrrs  r�test_otherwisez&ChooseDirectiveTestCase.test_otherwiseR�=������	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)z?
        Verify that `py:choose` blocks can be nested:
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="1">
            <div py:when="1" py:choose="3">
              <span py:when="2">2</span>
              <span py:when="3">3</span>
            </div>
          </div>
        </doc>zw<doc>
          <div>
            <div>
              <span>3</span>
            </div>
          </div>
        </doc>Nrrrs  r�test_nestingz$ChooseDirectiveTestCase.test_nesting[�A������	
�����=�=�?�)�)�4�)�8�
	:rc�z�td�}|jd|j�jd���y)z.
        Verify more complex nesting.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="1">
            <div py:when="1" py:choose="">
              <span py:when="2">OK</span>
              <span py:when="1">FAIL</span>
            </div>
          </div>
        </doc>�x<doc>
          <div>
            <div>
              <span>OK</span>
            </div>
          </div>
        </doc>Nrrrs  r�test_complex_nestingz,ChooseDirectiveTestCase.test_complex_nestingor2rc�z�td�}|jd|j�jd���y)z>
        Verify more complex nesting using otherwise.
        a<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="1">
            <div py:when="1" py:choose="2">
              <span py:when="1">FAIL</span>
              <span py:otherwise="">OK</span>
            </div>
          </div>
        </doc>r4Nrrrs  r�test_complex_nesting_otherwisez6ChooseDirectiveTestCase.test_complex_nesting_otherwise�r2rc�z�td�}|jd|j�jd���y)zs
        Verify that a when directive with a strip directive actually strips of
        the outer element.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="" py:strip="">
            <span py:otherwise="">foo</span>
          </div>
        </doc>z1<doc>
            <span>foo</span>
        </doc>Nrrrs  r�test_when_with_stripz,ChooseDirectiveTestCase.test_when_with_strip�r,rc�l�td�}|jtt|j	��y)zq
        Verify that a `when` directive outside of a `choose` directive is
        reported as an error.
        zZ<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:when="xy" />
        </doc>N�r�assertRaisesr�strrrs  r�test_when_outside_choosez0ChooseDirectiveTestCase.test_when_outside_choose��.��
����	
���.��T�]�]�_�Erc�l�td�}|jtt|j	��y)zw
        Verify that an `otherwise` directive outside of a `choose` directive is
        reported as an error.
        z]<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:otherwise="" />
        </doc>Nr;rs  r�test_otherwise_outside_choosez5ChooseDirectiveTestCase.test_otherwise_outside_choose�r?rc�l�td�}|jtt|j	��y)zw
        Verify that an `when` directive that doesn't have a `test` attribute
        is reported as an error.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="" py:strip="">
            <py:when>foo</py:when>
          </div>
        </doc>Nr;rs  r�test_when_without_testz.ChooseDirectiveTestCase.test_when_without_test�s.��
����
	
���.��T�]�]�_�Erc�~�td�}|jd|jd��jd���y)z�
        Verify that an `when` directive that doesn't have a `test` attribute
        works as expected as long as the parent `choose` directive has a test
        expression.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="foo" py:strip="">
            <py:when>foo</py:when>
          </div>
        </doc>�$<doc>
            foo
        </doc>�Yeah��fooNrrrs  r�,test_when_without_test_but_with_choose_valuezDChooseDirectiveTestCase.test_when_without_test_but_with_choose_value�sE������
	
�����=�=�V�=�,�3�3�T�3�B�	Drc�z�td�}|jd|j�jd���y)zf
        Verify that an `otherwise` directive can be used without a `test`
        attribute.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:choose="" py:strip="">
            <py:otherwise>foo</py:otherwise>
          </div>
        </doc>rENrrrs  r�test_otherwise_without_testz3ChooseDirectiveTestCase.test_otherwise_without_test�r,rc�z�td�}|jd|j�jd���y)�K
        Verify that the directive can also be used as an element.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:choose>
            <py:when test="1 == 1">1</py:when>
            <py:when test="2 == 2">2</py:when>
            <py:when test="3 == 3">3</py:when>
          </py:choose>
        </doc>z"<doc>
            1
        </doc>Nrrrs  r�test_as_elementz'ChooseDirectiveTestCase.test_as_element�s?������	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)�Q
        Verify that the directive works as expected in a text template.
        z�#choose
          #when 1 == 1
            1
          #end
          #when 2 == 2
            2
          #end
          #when 3 == 3
            3
          #end
        #endz            1
Nr�rrrrrs  r�test_in_text_templatez-ChooseDirectiveTestCase.test_in_text_template�s>���
�
��	
���.�����/�/��/�>�	@rN)r#r$r%r&r+r.r1r5r7r9r>rArCrIrKrNrRr'rrr)r)@sM��0�:�:�:�(:�(:�(:�F�F�
F�
D�:�
:�@rr)c�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�DefDirectiveTestCasez*Tests for the `py:def` template directive.c�z�td�}|jd|j�jd���y)z|
        Verify that a named template function with a strip directive actually
        strips of the outer element.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:def="echo(what)" py:strip="">
            <b>${what}</b>
          </div>
          ${echo('foo')}
        </doc>�+<doc>
            <b>foo</b>
        </doc>Nrrrs  r�test_function_with_stripz-DefDirectiveTestCase.test_function_with_strip�?��
����	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          <p py:def="echo(greeting, name='world')" class="message">
            ${greeting}, ${name}!
          </p>
          <div py:replace="echo('hello')"></div>
        </div>z[<div>
          <p class="message">
            hello, world!
          </p>
        </div>rrrs  r�test_exec_in_replacez)DefDirectiveTestCase.test_exec_in_replace�?������	
�����=�=�?�)�)�4�)�8�		:rc�z�td�}|jd|j�jd���y)rMz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:def function="echo(what)">
            <b>${what}</b>
          </py:def>
          ${echo('foo')}
        </doc>rVNrrrs  rrNz$DefDirectiveTestCase.test_as_element#�?������	
�����=�=�?�)�)�4�)�8�	:rc�~�td�}|jd|jd��jd���y)z�
        Verify that a template function defined inside a conditional block can
        be called from outside that block.
        a*<doc xmlns:py="http://genshi.edgewall.org/">
          <py:if test="semantic">
            <strong py:def="echo(what)">${what}</strong>
          </py:if>
          <py:if test="not semantic">
            <b py:def="echo(what)">${what}</b>
          </py:if>
          ${echo('foo')}
        </doc>z3<doc>
          <strong>foo</strong>
        </doc>T)�semanticNrrrs  r�test_nested_defsz%DefDirectiveTestCase.test_nested_defs1sE��
����	
�����=�=�$�=�/�6�6��6�E�	Grc�z�td�}|jd|j�jd���y)zN
        Verify that keyword arguments work with `py:def` directives.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <b py:def="echo(what, bold=False)" py:strip="not bold">${what}</b>
          ${echo('foo')}
        </doc>z"<doc>
          foo
        </doc>Nrrrs  r�test_function_with_default_argz3DefDirectiveTestCase.test_function_with_default_argCs?������	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:def function="echo(what)">${what or 'something'}</py:def>
          <p class="${echo('foo')}">bar</p>
        </doc>z5<doc>
          <p class="foo">bar</p>
        </doc>rrrs  r�test_invocation_in_attributez1DefDirectiveTestCase.test_invocation_in_attributeOr/rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:def function="echo()">${None}</py:def>
          <p class="${echo()}">bar</p>
        </doc>z)<doc>
          <p>bar</p>
        </doc>rrrs  r�!test_invocation_in_attribute_nonez6DefDirectiveTestCase.test_invocation_in_attribute_noneXr/rc�v�d�}td�}|jtt|j	|���y)Nc��t�)N)�	TypeErrorr'rr�badfunczEDefDirectiveTestCase.test_function_raising_typeerror.<locals>.badfuncbs���Orz�<html xmlns:py="http://genshi.edgewall.org/">
          <div py:def="dobadfunc()">
            ${badfunc()}
          </div>
          <div py:content="dobadfunc()"/>
        </html>)rj)rr<ri�listr)rrjrs   r�test_function_raising_typeerrorz4DefDirectiveTestCase.test_function_raising_typeerroras5��	�����	
���)�T�4�=�=��=�+I�Jrc�z�td�}|jd|j�jd���y)Na<doc xmlns:py="http://genshi.edgewall.org/">
          <head py:match="head">${select('*')}</head>
          <head>
            <py:def function="maketitle(test)"><b py:replace="test" /></py:def>
            <title>${maketitle(True)}</title>
          </head>
        </doc>�?<doc>
          <head><title>True</title></head>
        </doc>rrrs  r�test_def_in_matchedz(DefDirectiveTestCase.test_def_in_matchedls=������	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)rPz�
          #def echo(greeting, name='world')
            ${greeting}, ${name}!
          #end
          ${echo('Hi', name='you')}
        z)
                      Hi, you!

        NrrQrs  rrRz*DefDirectiveTestCase.test_in_text_templatexsA����
��	
�����]�]�_�
#�
#�T�
#�
2�	4rc�z�td�}|jd|j�jd���y)zi
        Verify that a named template function using "star arguments" works as
        expected.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:def="f(*args, **kwargs)">
            ${repr(args)}
            ${repr(sorted(kwargs.items()))}
          </div>
          ${f(1, 2, a=3, b=4)}
        </doc>zi<doc>
          <div>
            [1, 2]
            [('a', 3), ('b', 4)]
          </div>
        </doc>Nrrrs  r�test_function_with_star_argsz1DefDirectiveTestCase.test_function_with_star_args�sA��
����	
����
�=�=�?�)�)�4�)�8�	:rN)r#r$r%r&rWrZrNr`rbrdrfrlrorRrrr'rrrTrTs>��4�
:�:�:�G�$
:�:�:�	K�
:�
4�:rrTc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ForDirectiveTestCasez*Tests for the `py:for` template directive.c	��td�}|jd|jtdd���j	d���y)zk
        Verify that the combining the `py:for` directive with `py:strip` works
        correctly.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:for="item in items" py:strip="">
            <b>${item}</b>
          </div>
        </doc>�}<doc>
            <b>1</b>
            <b>2</b>
            <b>3</b>
            <b>4</b>
            <b>5</b>
        </doc>r
�rNr�rrr�rangerrs  r�test_loop_with_stripz)ForDirectiveTestCase.test_loop_with_strip�sM��
����
	
�����=�=�u�Q��{�=�3�:�:�D�:�I�
	Krc	��td�}|jd|jtdd���j	d���y)rMz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:for each="item in items">
            <b>${item}</b>
          </py:for>
        </doc>rvr
rwrNrrxrs  rrNz$ForDirectiveTestCase.test_as_element�sM������
	
�����=�=�u�Q��{�=�3�:�:�D�:�I�
	Krc�~�td�}|jd|jd��jd���y)zC
        Verify that assignment to tuples works correctly.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:for each="k, v in items">
            <p>key=$k, value=$v</p>
          </py:for>
        </doc>zX<doc>
            <p>key=a, value=1</p>
            <p>key=b, value=2</p>
        </doc>)��ar
��brrNrrrs  r�test_multi_assignmentz*ForDirectiveTestCase.test_multi_assignment�sE������
	
�����=�=�';�=�<�����-�		/rc	��td�}|jd|jtddg���j	d���y)�J
        Verify that assignment to nested tuples works correctly.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:for each="idx, (k, v) in items">
            <p>$idx: key=$k, value=$v</p>
          </py:for>
        </doc>z^<doc>
            <p>0: key=a, value=1</p>
            <p>1: key=b, value=2</p>
        </doc>r}rrNr)rrr�	enumeraterrs  r�test_nested_assignmentz+ForDirectiveTestCase.test_nested_assignment�sN������
	
�����=�=�y�(�H�1E�'F�=�G�����-�		/rc��tdd��}	t|jd���|jd�y#t$�r}t|�dk(st|�dk(sJ�t
j�\}}}|j}g}|jr*|j}|j|�|jr�*trd	nd
}|jd|z|djjj�|jd|djjj�|jd
|dj �Yd}~yd}~wwxYw)r�z�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:for each="item in foo">
            $item
          </py:for>
        </doc>�	test.html��filename�rGzExpected TemplateRuntimeErrorziteration over non-sequencez'int' object is not iterablezu'iter(foo)'z'iter(foo)'z<Expression %s>���rN)rrkr�failrir=�sys�exc_info�tb_next�appendrr�tb_frame�f_code�co_name�co_filename�	tb_lineno)	rr�e�exc_type�	exc_value�
exc_traceback�frame�frames�expected_iter_strs	         r�test_not_iterablez&ForDirectiveTestCase.test_not_iterable�s<����(�	)��
	6�����2��&�'��I�I�5�6���	6���F�;�;���F�<�<�
>�=�14����.�H�i��!�)�)�E��F��-�-��
�
���
�
�e�$��-�-�3=��-�����.�1B�B�#�B�Z�0�0�7�7�?�?�
A����[�#�B�Z�0�0�7�7�C�C�
E����Q��r�
� 4� 4�5�5��	6�s�,<�
E�A9E�BE�Ec�0�	tdd��j�|jd�y#t$r]}|j	d|j
�tjdddkDr!|j	d|j�Yd}~yYd}~yd}~wwxYw)z9
        Verify an empty 'for' value is an error
        z�<doc xmlns:py="http://genshi.edgewall.org/">
              <py:for each="">
                empty
              </py:for>
            </doc>r�r��ExpectedTemplateSyntaxErrorNr)r�)	rrr�rrr�r��version_info�lineno�rr�s  r�test_for_with_empty_valuez.ForDirectiveTestCase.test_for_with_empty_value�s���
	.���!,�	
-�.6�X�Z��I�I�3�4��"�	.����[�!�*�*�5������#�e�+�� � ��A�H�H�-�-�,��	.�s�,/�	B�AB�BN)
r#r$r%r&rzrNr�r�r�r�r'rrrtrt�s%��4�K�$K�"
/�
/�6�8.rrtc��eZdZdZd�Zd�Zy)�IfDirectiveTestCasez)Tests for the `py:if` template directive.c��td�}|jd|jdd��jd���y)zj
        Verify that the combining the `py:if` directive with `py:strip` works
        correctly.
        zk<doc xmlns:py="http://genshi.edgewall.org/">
          <b py:if="foo" py:strip="">${bar}</b>
        </doc>�$<doc>
          Hello
        </doc>T�Hello�rH�barNrrrs  rrzz(IfDirectiveTestCase.test_loop_with_stripsG��
����	
�����=�=�T�w�=�7�>�>��>�M�	Orc��td�}|jd|jdd��jd���y)rMzf<doc xmlns:py="http://genshi.edgewall.org/">
          <py:if test="foo">${bar}</py:if>
        </doc>r�Tr�r�Nrrrs  rrNz#IfDirectiveTestCase.test_as_elementsG������	
�����=�=�T�w�=�7�>�>��>�M�	OrN)r#r$r%r&rzrNr'rrr�r�s��3�
O�	Orr�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�MatchDirectiveTestCasez,Tests for the `py:match` template directive.c�z�td�}|jd|j�jd���y)��
        Verify that a match template can produce the same kind of element that
        it matched without entering an infinite recursion.
        z�<doc xmlns:py="http://genshi.edgewall.org/">
          <elem py:match="elem" py:strip="">
            <div class="elem">${select('text()')}</div>
          </elem>
          <elem>Hey Joe</elem>
        </doc>�@<doc>
            <div class="elem">Hey Joe</div>
        </doc>Nrrrs  r�test_with_stripz&MatchDirectiveTestCase.test_with_strip*rXrc�z�td�}|jd|j�jd���y)r�z�<doc xmlns:py="http://genshi.edgewall.org/">
          <elem py:match="elem">
            <div class="elem">${select('text()')}</div>
          </elem>
          <elem>Hey Joe</elem>
        </doc>zc<doc>
          <elem>
            <div class="elem">Hey Joe</div>
          </elem>
        </doc>Nrrrs  r�test_without_stripz)MatchDirectiveTestCase.test_without_strip9sA��
����	
�����=�=�?�)�)�4�)�8�		:rc�z�td�}|jd|j�jd���y)rMz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:match path="elem">
            <div class="elem">${select('text()')}</div>
          </py:match>
          <elem>Hey Joe</elem>
        </doc>r�Nrrrs  rrNz&MatchDirectiveTestCase.test_as_elementJr]rc�z�td�}|jd|j�jd���y)z�
        Match directives are applied recursively, meaning that they are also
        applied to any content they may have produced themselves:
        a#<doc xmlns:py="http://genshi.edgewall.org/">
          <elem py:match="elem">
            <div class="elem">
              ${select('*')}
            </div>
          </elem>
          <elem>
            <subelem>
              <elem/>
            </subelem>
          </elem>
        </doc>z�<doc>
          <elem>
            <div class="elem">
              <subelem>
              <elem>
            <div class="elem">
            </div>
          </elem>
            </subelem>
            </div>
          </elem>
        </doc>Nrrrs  r�test_recursive_match_1z-MatchDirectiveTestCase.test_recursive_match_1XsA��
����	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)z�
        When two or more match templates match the same element and also
        themselves output the element they match, avoiding recursion is even
        more complex, but should work.
        aS<html xmlns:py="http://genshi.edgewall.org/">
          <body py:match="body">
            <div id="header"/>
            ${select('*')}
          </body>
          <body py:match="body">
            ${select('*')}
            <div id="footer"/>
          </body>
          <body>
            <h1>Foo</h1>
          </body>
        </html>z�<html>
          <body>
            <div id="header"/><h1>Foo</h1>
            <div id="footer"/>
          </body>
        </html>Nrrrs  r�test_recursive_match_2z-MatchDirectiveTestCase.test_recursive_match_2vsA������	
����
�M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)Na1<test xmlns:py="http://genshi.edgewall.org/">
          <py:match path="b[@type='bullet']">
            <bullet>${select('*|text()')}</bullet>
          </py:match>
          <py:match path="group[@type='bullet']">
            <ul>${select('*')}</ul>
          </py:match>
          <py:match path="b">
            <generic>${select('*|text()')}</generic>
          </py:match>

          <b>
            <group type="bullet">
              <b type="bullet">1</b>
              <b type="bullet">2</b>
            </group>
          </b>
        </test>
        z{<test>
            <generic>
            <ul><bullet>1</bullet><bullet>2</bullet></ul>
          </generic>
        </test>rrrs  r�test_recursive_match_3z-MatchDirectiveTestCase.test_recursive_match_3�s?����
��&	
�����M�M�O�*�*�D�*�9�		;rc�z�td�}|jd|j�jd���y)z:
        See http://genshi.edgewall.org/ticket/77
        aM<html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:py="http://genshi.edgewall.org/">
          <body py:match="body" py:content="select('*')" />
          <h1 py:match="h1">
            ${select('text()')}
            Goodbye!
          </h1>
          <body>
            <h1>Hello!</h1>
          </body>
        </html>z�<html xmlns="http://www.w3.org/1999/xhtml">
          <body><h1>
            Hello!
            Goodbye!
          </h1></body>
        </html>Nrrrs  r�test_not_match_selfz*MatchDirectiveTestCase.test_not_match_self�sA���
�
��	
����
�M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)zD
        See http://genshi.edgewall.org/ticket/77#comment:1
        av<html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:py="http://genshi.edgewall.org/">
          <body py:match="body" py:content="select('*')" />
          <h1 py:match="h1">
            <text>
              ${select('text()')}
            </text>
            Goodbye!
          </h1>
          <body>
            <h1>Hello!</h1>
          </body>
        </html>z�<html xmlns="http://www.w3.org/1999/xhtml">
          <body><h1>
            <text>
              Hello!
            </text>
            Goodbye!
          </h1></body>
        </html>Nrrrs  r�test_select_text_in_elementz2MatchDirectiveTestCase.test_select_text_in_element�sA������	
�����M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:match="elem" py:attrs="select('@*')">
            ${select('text()')}
          </div>
          <elem id="joe">Hey Joe</elem>
        </doc>zR<doc>
          <div id="joe">
            Hey Joe
          </div>
        </doc>rrrs  r�test_select_all_attrsz,MatchDirectiveTestCase.test_select_all_attrs�r[rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:match="elem" py:attrs="select('@*')">
            ${select('text()')}
          </div>
          <elem>Hey Joe</elem>
        </doc>zI<doc>
          <div>
            Hey Joe
          </div>
        </doc>rrrs  r�test_select_all_attrs_emptyz2MatchDirectiveTestCase.test_select_all_attrs_empty�r[rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:match="elem">
            Hey ${select('text()')} ${select('@*')}
          </div>
          <elem title="Cool">Joe</elem>
        </doc>zN<doc>
          <div>
            Hey Joe Cool
          </div>
        </doc>rrrs  r�test_select_all_attrs_in_bodyz4MatchDirectiveTestCase.test_select_all_attrs_in_body�r[rc�z�td�}|jd|j�jd���y)Nz�<doc xmlns:py="http://genshi.edgewall.org/">
          <py:def function="maketitle(test)"><b py:replace="test" /></py:def>
          <head py:match="head">${select('*')}</head>
          <head><title>${maketitle(True)}</title></head>
        </doc>rnrrrs  r�test_def_in_matchz(MatchDirectiveTestCase.test_def_in_matchs=������
	
�����=�=�?�)�)�4�)�8�	:rc���td�}|jd|jd��jd���|jd|jd��jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          <span py:match="*[name()=$tagname]">
            Hello ${select('@name')}
          </span>
          <greeting name="Dude"/>
        </div>zN<div>
          <span>
            Hello Dude
          </span>
        </div>�greeting)�tagnamerz6<div>
          <greeting name="Dude"/>
        </div>�sayhellorrs  r�test_match_with_xpath_variablez5MatchDirectiveTestCase.test_match_with_xpath_variablesw������	
�����=�=��=�4�;�;�T�;�J�		L�
	
�����=�=��=�4�;�;�T�;�J�	Lrc�z�td�}|jd|j�jd���y)Nz�<html xmlns:py="http://genshi.edgewall.org/">
          <div py:match="foo">I said <q py:content="select('text()')">something</q>.</div>
          <foo>bar</foo>
        </html>z><html>
          <div>I said <q>bar</q>.</div>
        </html>rrrs  r�test_content_directive_in_matchz6MatchDirectiveTestCase.test_content_directive_in_matchs=������	
�����M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)Na[<html xmlns:py="http://genshi.edgewall.org/">
          <body py:match="body">${select('*')}</body>
          <head py:match="head">${select('title')}</head>
          <body py:match="body">${select('*')}<hr /></body>
          <head><title>Welcome to Markup</title></head>
          <body><h2>Are you ready to mark up?</h2></body>
        </html>z�<html>
          <head><title>Welcome to Markup</title></head>
          <body><h2>Are you ready to mark up?</h2><hr/></body>
        </html>rrrs  r�test_cascaded_matchesz,MatchDirectiveTestCase.test_cascaded_matches$s?������	
�����M�M�O�*�*�D�*�9�	;rc��td�}td�D�cgc]}d|z��	}}ttd�D�cgc]	}d|z|f��c}�}|jd|j	||��jd���ycc}wcc}w)Na_<html xmlns:py="http://genshi.edgewall.org/">
          <input py:match="form//input" py:attrs="select('@*')"
                 value="${values[str(select('@name'))]}" />
          <form><p py:for="field in fields">
            <label>${field.capitalize()}</label>
            <input type="text" name="${field}" />
          </p></form>
        </html>�zhello_%saY<html>
          <form><p>
            <label>Hello_0</label>
            <input value="0" type="text" name="hello_0"/>
          </p><p>
            <label>Hello_1</label>
            <input value="1" type="text" name="hello_1"/>
          </p><p>
            <label>Hello_2</label>
            <input value="2" type="text" name="hello_2"/>
          </p><p>
            <label>Hello_3</label>
            <input value="3" type="text" name="hello_3"/>
          </p><p>
            <label>Hello_4</label>
            <input value="4" type="text" name="hello_4"/>
          </p></form>
        </html>)�fields�valuesr)rry�dictrrr)rr�ir�r�s     r�test_multiple_matchesz,MatchDirectiveTestCase.test_multiple_matches1s�������+0��(�3�Q�*�q�.�3��3��E�!�H�=�q�
�Q���*�=�>������"�M�M���M�?�����.�%	0��4��=s
�B�Bc�z�td�}|jd|j�jd���y)Nz�<html xmlns:py="http://genshi.edgewall.org/"
                                       xmlns:x="http://www.example.org/">
          <div py:match="x:foo">Foo</div>
          <foo xmlns="http://www.example.org/"/>
        </html>zQ<html xmlns:x="http://www.example.org/">
          <div>Foo</div>
        </html>rrrs  r�test_namespace_contextz-MatchDirectiveTestCase.test_namespace_contextPs=������	
�����M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)Nz�<html xmlns:py="http://genshi.edgewall.org/">
          <p py:match="body/p[1]" class="first">${select('*|text()')}</p>
          <body>
            <p>Foo</p>
            <p>Bar</p>
          </body>
        </html>zu<html>
          <body>
            <p class="first">Foo</p>
            <p>Bar</p>
          </body>
        </html>rrrs  r�"test_match_with_position_predicatez9MatchDirectiveTestCase.test_match_with_position_predicate\�?������	
����
�M�M�O�*�*�D�*�9�	;rc�z�td�}|jd|j�jd���y)Nz�<html xmlns:py="http://genshi.edgewall.org/">
          <p py:match="body//p" class="para">${select('*|text()')}</p>
          <body>
            <p>Foo</p>
            <div><p>Bar</p></div>
          </body>
        </html>z�<html>
          <body>
            <p class="para">Foo</p>
            <div><p class="para">Bar</p></div>
          </body>
        </html>rrrs  r�test_match_with_closurez.MatchDirectiveTestCase.test_match_with_closurekr�rc�z�td�}|jd|j�jd���y)Nz�<html xmlns:py="http://genshi.edgewall.org/">
          <p py:match="body/p" class="para">${select('*|text()')}</p>
          <body>
            <p>Foo</p>
            <div><p>Bar</p></div>
          </body>
        </html>z<html>
          <body>
            <p class="para">Foo</p>
            <div><p>Bar</p></div>
          </body>
        </html>rrrs  r�test_match_without_closurez1MatchDirectiveTestCase.test_match_without_closurezr�rc�z�td�}|jd|j�jd���y)NaM<html xmlns:py="http://genshi.edgewall.org/">
          <py:match path="body" once="true"><body>
            <div id="wrap">
              ${select("*")}
            </div>
          </body></py:match>
          <body>
            <p>Foo</p>
          </body>
          <body>
            <p>Bar</p>
          </body>
        </html>z�<html>
          <body>
            <div id="wrap">
              <p>Foo</p>
            </div>
          </body>
          <body>
            <p>Bar</p>
          </body>
        </html>rrrs  r�test_match_with_once_attributez5MatchDirectiveTestCase.test_match_with_once_attribute�s?������	
���	��M�M�O�*�*�D�*�9�		;rc�z�td�}|jd|j�jd���y)NaF<doc xmlns:py="http://genshi.edgewall.org/">
          <py:match path="elem" recursive="false"><elem>
            <div class="elem">
              ${select('*')}
            </div>
          </elem></py:match>
          <elem>
            <subelem>
              <elem/>
            </subelem>
          </elem>
        </doc>z�<doc>
          <elem>
            <div class="elem">
              <subelem>
              <elem/>
            </subelem>
            </div>
          </elem>
        </doc>rrrs  r�#test_match_with_recursive_attributez:MatchDirectiveTestCase.test_match_with_recursive_attribute�s?������	
�����=�=�?�)�)�4�)�8�	:rc���td�}|j�jdd��}tjd|�}|jd|�|j
dt|��y)Na6<doc xmlns:py="http://genshi.edgewall.org/">
          <div py:match="div[@id='content']" py:attrs="select('@*')" once="true">
            <ul id="tabbed_pane" />
            ${select('*')}
          </div>

          <body py:match="body" once="true" buffer="false">
            ${select('*|text()')}
          </body>
          <body py:match="body" once="true" buffer="false">
              ${select('*|text()')}
          </body>

          <body>
            <div id="content">
              <h1>Ticket X</h1>
            </div>
          </body>
        </doc>�xhtml)�doctype�tabbed_paner
)rrr�re�findall�assertNotEqualr�len)rr�output�matchess    r�-test_triple_match_produces_no_duplicate_itemszDMatchDirectiveTestCase.test_triple_match_produces_no_duplicate_items�sb������&����'�'���'�A���*�*�]�F�3�����D�'�*�����C��L�)rc�v�td�}|jd|j�j��y)Nz�<html xmlns:py="http://genshi.edgewall.org/">
          <py:match path="body[@id='content']/h2" />
          <head py:match="head" />
          <head py:match="head" />
          <head />
          <body />
        </html>z:<html>
          <head/>
          <body/>
        </html>rrs  r�test_match_multiple_times1z1MatchDirectiveTestCase.test_match_multiple_times1�s:������	
�����M�M�O�*�*�,�	.rc�v�td�}|jd|j�j��y)Na<html xmlns:py="http://genshi.edgewall.org/">
          <py:match path="body/div[@id='properties']" />
          <head py:match="head" />
          <head py:match="head" />
          <head/>
          <body>
            <div id="properties">Foo</div>
          </body>
        </html>zK<html>
          <head/>
          <body>
          </body>
        </html>rrs  r�test_match_multiple_times2z1MatchDirectiveTestCase.test_match_multiple_times2�s:������	
�����M�M�O�*�*�,�		.rc�v�td�}|jd|j�j��y)Na<?xml version="1.0"?>
          <root xmlns:py="http://genshi.edgewall.org/">
            <py:match path="foo/bar">
              <zzzzz/>
            </py:match>
            <foo>
              <bar/>
              <bar/>
            </foo>
            <bar/>
          </root>z�<?xml version="1.0"?>
<root>
            <foo>
              <zzzzz/>
              <zzzzz/>
            </foo>
            <bar/>
          </root>rrs  r�test_match_multiple_times3z1MatchDirectiveTestCase.test_match_multiple_times3�s:���
�
��	
�����m�m�o�,�,�.�
	0rN)r#r$r%r&r�r�rNr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r'rrr�r�'s���6�
:�:�":�:�<;�4;�4;�,;�4:�:�:�:�L� ;�;�0�>
;�
;�
;�
;�;�2:�0*�2.�.�"0rr�c��eZdZdZd�Zy)�ContentDirectiveTestCasez.Tests for the `py:content` template directive.c��	tdd��j�|jd�y#t$rB}|j	d|j
�|j	d|j�Yd}~yd}~wwxYw)Nzq<doc xmlns:py="http://genshi.edgewall.org/">
              <py:content foo="">Foo</py:content>
            </doc>r�r��Expected TemplateSyntaxErrorr�rrr�rrr�r�r�s  rrNz(ContentDirectiveTestCase.test_as_elementsf��	*��� +�
-�-5�X�Z��I�I�4�5��"�	*����[�!�*�*�5����Q����)�)��	*���,/�	A:�8A5�5A:N)r#r$r%r&rNr'rrr�r�s
��8�*rr�c��eZdZdZd�Zd�Zy)�ReplaceDirectiveTestCasez.Tests for the `py:replace` template directive.c��	tdd��j�|jd�y#t$rB}|j	d|j
�|j	d|j�Yd}~yd}~wwxYw)zy
        Verify that the directive raises an apprioriate exception when an empty
        expression is supplied.
        zl<doc xmlns:py="http://genshi.edgewall.org/">
              <elem py:replace="">Foo</elem>
            </doc>r�r�r�rNr�r�s  r�test_replace_with_empty_valuez6ReplaceDirectiveTestCase.test_replace_with_empty_value'sf��
	*��� +�
-�-5�X�Z��I�I�4�5��"�	*����[�!�*�*�5����Q����)�)��	*�r�c��tdd��}|jd|jd��jd���y)Nzb<div xmlns:py="http://genshi.edgewall.org/">
          <py:replace value="title" />
        </div>r�r�z#<div>
          Test
        </div>�Test)�titlerrrs  rrNz(ReplaceDirectiveTestCase.test_as_element5sF����'�)��	
�����=�=�v�=�.�5�5�t�5�D�	FrN)r#r$r%r&r�rNr'rrr�r�$s��8�*�Frr�c��eZdZdZd�Zd�Zy)�StripDirectiveTestCasez,Tests for the `py:strip` template directive.c�z�td�}|jd|j�jd���y)Nzl<div xmlns:py="http://genshi.edgewall.org/">
          <div py:strip="False"><b>foo</b></div>
        </div>z4<div>
          <div><b>foo</b></div>
        </div>rrrs  r�test_strip_falsez'StripDirectiveTestCase.test_strip_falseA�=������	
�����=�=�?�)�)�4�)�8�	:rc�z�td�}|jd|j�jd���y)Nzg<div xmlns:py="http://genshi.edgewall.org/">
          <div py:strip=""><b>foo</b></div>
        </div>z)<div>
          <b>foo</b>
        </div>rrrs  r�test_strip_emptyz'StripDirectiveTestCase.test_strip_emptyIrrN)r#r$r%r&rr	r'rrrr>s��6�:�:rrc�L�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�WithDirectiveTestCasez+Tests for the `py:with` template directive.c�~�td�}|jd|jd��jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          ${x}
          <span py:with="x = x * 2" py:replace="x"/>
          ${x}
        </div>z;<div>
          42
          84
          42
        </div>�*��xrrrs  r�test_shadowingz$WithDirectiveTestCase.test_shadowingUsD������
	
�����=�=�2�=�&�-�-�t�-�<�		>rc�~�td�}|jd|jd��jd���y)Nzn<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="x = x * 2">${x}</py:with>
        </div>z!<div>
          84
        </div>r
rrrrs  rrNz%WithDirectiveTestCase.test_as_elementa�B������	
�����=�=�2�=�&�-�-�t�-�<�	>rc�~�td�}|jd|jd��jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="
            foo = 'bar';
            foo = foo.replace('r', 'z')
          ">
            $foo
          </py:with>
        </div>z$<div>
            baz
        </div>r
rrrrs  r�test_multiple_vars_same_namez2WithDirectiveTestCase.test_multiple_vars_same_nameisB������	
�����=�=�2�=�&�-�-�t�-�<�	>rc�~�td�}|jd|jd��jd���y)Nz|<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="x = y = z = 1">${x} ${y} ${z}</py:with>
        </div>z$<div>
          1 1 1
        </div>r
rrrrs  r�$test_multiple_vars_single_assignmentz:WithDirectiveTestCase.test_multiple_vars_single_assignmentvrrc�~�td�}|jd|jd��jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="x, (y, z) = (1, (2, 3))">${x} ${y} ${z}</py:with>
        </div>z$<div>
          1 2 3
        </div>r
rrrrs  r�"test_nested_vars_single_assignmentz8WithDirectiveTestCase.test_nested_vars_single_assignment~rrc��td�}|jddz|jd��jd���y)Nz<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="x = x * 2; y = x / 2;">${x} ${y}</py:with>
        </div>z$<div>
          84 %s
        </div>gE@r
rrrrs  r�%test_multiple_vars_trailing_semicolonz;WithDirectiveTestCase.test_multiple_vars_trailing_semicolon�sK������	
������"�m�m�b�m�1�8�8�$�8�G�	Irc�z�td�}|jd|j�jd���y)Nz�<div xmlns:py="http://genshi.edgewall.org/">
          <py:with vars="x = 'here is a semicolon: ;'; y = 'here are two semicolons: ;;' ;">
            ${x}
            ${y}
          </py:with>
        </div>z_<div>
            here is a semicolon: ;
            here are two semicolons: ;;
        </div>rrrs  r�test_semicolon_escapez+WithDirectiveTestCase.test_semicolon_escape�s?������	
�����=�=�?�)�)�4�)�8�	:rc��td�}|jd|jddi��jd���y)z�
        Verify that the usual template expression AST transformations are
        applied despite the code being compiled to a `Suite` object.
        z�<div xmlns:py="http://genshi.edgewall.org/">
          <span py:with="bar=foo.bar">
            $bar
          </span>
        </div>zF<div>
          <span>
            42
          </span>
        </div>r�r
rGNrrrs  r�test_ast_transformationz-WithDirectiveTestCase.test_ast_transformation�sK��
����
	
�����=�=�e�R�[�=�1�8�8�$�8�G�		Irc�z�td�}|jd|j�jd���y)Nu�<div xmlns:py="http://genshi.edgewall.org/">
          <span py:with="weeks=(u'一', u'二', u'三', u'四', u'五', u'六', u'日')">
            $weeks
          </span>
        </div>uY<div>
          <span>
            一二三四五六日
          </span>
        </div>rrrs  r�test_unicode_exprz'WithDirectiveTestCase.test_unicode_expr�s?������
	
�����=�=�?�)�)�4�)�8�		:rc�z�td�}|jd|j�jd���y)zI
        Verify that an empty py:with works (useless, but legal)
        zY<div xmlns:py="http://genshi.edgewall.org/">
          <span py:with="">Text</span></div>z'<div>
          <span>Text</span></div>Nrrrs  r�test_with_empty_valuez+WithDirectiveTestCase.test_with_empty_value�s@���0�1��	
���%�&*�m�m�o�&<�&<�d�&<�&K�	MrN)r#r$r%r&rrNrrrrrrr r"r'rrrrRs:��5�
>�>�>�>�>�I�
:�I� 
:�Mrrc��tj�}|jtjt
��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjtd��|jtjt d��|S)N�test)�unittest�	TestSuite�addTest�doctest�DocTestSuiter�	makeSuiter
r)rTrtr�r�r�r�rr)�suites rr+r+�s0����� �E�	�M�M�'�&�&�z�2�3�	�M�M�(�$�$�%;�V�D�E�	�M�M�(�$�$�%<�f�E�F�	�M�M�(�$�$�%9�6�B�C�	�M�M�(�$�$�%9�6�B�C�	�M�M�(�$�$�%8�&�A�B�	�M�M�(�$�$�%;�V�D�E�	�M�M�(�$�$�%=�v�F�G�	�M�M�(�$�$�%=�v�F�G�	�M�M�(�$�$�%;�V�D�E�	�M�M�(�$�$�%:�F�C�D��Lr�__main__r+)�defaultTest)r(r�r�r%�
genshi.compatr�genshi.templaterrrrr�TestCaser
r)rTrtr�r�r�r�rrr+r#�mainr'rr�<module>r2s���	�
��$�F�F�%:�X�.�.�%:�PA@�h�/�/�A@�HT:�8�,�,�T:�nn.�8�,�,�n.�bO�(�+�+�O�6^0�X�.�.�^0�^*�x�0�0�*�F�x�0�0�F�4:�X�.�.�:�(lM�H�-�-�lM�^
��z���H�M�M�g�&�r