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__/text.cpython-312.pyc
�

EMab�"����ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZGd�dej�Z
Gd�dej�Zd	�Zed
k(rej"d��yy)
�N)�TemplateSyntaxError)�TemplateLoader)�OldTextTemplate�NewTextTemplatec�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�OldTextTemplateTestCase�#Tests for text template processing.c�:�tjd��|_y�N�markup_test)�suffix��tempfile�mkdtemp�dirname��selfs �</usr/lib/python3/dist-packages/genshi/template/tests/text.py�setUpzOldTextTemplateTestCase.setUp����'�'�}�=���c�B�tj|j�y�N��shutil�rmtreerrs r�tearDownz OldTextTemplateTestCase.tearDown����
�
�d�l�l�#rc�z�td�}|jd|j�jd���y)Nz	\#escapedz#escaped��encoding�r�assertEqual�generate�render�r�tmpls  r�
test_escapingz%OldTextTemplateTestCase.test_escaping"s0���|�,������T�]�]�_�%;�%;�T�%;�%J�Krc�z�td�}|jd|j�jd���y)Nz## a comment�r r"r&s  r�test_commentz$OldTextTemplateTestCase.test_comment&s0���~�.������T�]�]�_�3�3�T�3�B�Crc�z�td�}|jd|j�jd���y)Nz\## escaped commentz## escaped commentr r"r&s  r�test_comment_escapingz-OldTextTemplateTestCase.test_comment_escaping*s6���5�6�����-�����/�/��/�>�	@rc�~�td�}|jd|jd��jd���y)Nz4
        #if foo
          bar
        #end 'if foo'�
F��foor r"r&s  r�test_end_with_argsz*OldTextTemplateTestCase.test_end_with_args/s<��� ���	
����t�}�}��}�7�>�>��>�M�Nrc��djd�}t|d��}|jd|jdd��j	d���y�N�
$fooö$barz
iso-8859-1r �xöy�x�y�r1�bar)�encoderr#r$r%�r�textr's   r�test_latin1_encodedz+OldTextTemplateTestCase.test_latin1_encoded6�M���%�%�l�3���t�l�;���������3�C��8�?�?��?�N�	Prc��d}t|�}|jd|jdd��jd���y�Nr5r6r7r8r9r r"r<s   r�test_unicode_inputz*OldTextTemplateTestCase.test_unicode_input<�@�����t�$���������3�C��8�?�?��?�N�	Prc��td�}|jd|jtd���j	d���y)NzHYour items:

        #for item in items
          * ${item}
        #endz7Your items:

          * 0
          * 1
          * 2
���itemsr �rr#r$�ranger%r&s  r�test_empty_lines1z)OldTextTemplateTestCase.test_empty_lines1BsH��� ���
	
����

�]�]��q��]�"�)�)�4�)�8�	:rc��td�}|jd|jtd���j	d���y)NzIYour items:

        #for item in items
          * ${item}

        #endz:Your items:

          * 0

          * 1

          * 2

rErFr rHr&s  r�test_empty_lines2z)OldTextTemplateTestCase.test_empty_lines2OsH��� ���	
����
�]�]��q��]�"�)�)�4�)�8�	:rc��ttjj|jd�d�}	|jdj
d��|j�ttjj|jd�d�}	|jdj
d��|j�t|jg�}|jdt��}|jd|j�jd�	��y#|j�wxYw#|j�wxYw)
N�	tmpl1.txt�wbz	Included
�utf-8�	tmpl2.txtz~----- Included data below this line -----
            #include tmpl1.txt
            ----- Included data above this line -----��clszh----- Included data below this line -----
Included
            ----- Included data above this line -----r )�open�os�path�joinr�writer;�closer�loadrr#r$r%�r�file1�file2�loaderr's     r�test_includez$OldTextTemplateTestCase.test_include`s����R�W�W�\�\�$�,�,��<�d�C��	��K�K�
�,�,�W�5�6��K�K�M��R�W�W�\�\�$�,�,��<�d�C��	��K�K�9�9?����
J�
�K�K�M������/���{�{�;�O�{�<�����9�����/�/��/�>�	@��
�K�K�M��
�K�K�M��� D)� D>�)D;�>EN)�__name__�
__module__�__qualname__�__doc__rrr(r+r-r2r>rBrJrLr_�rrrrsC��-�>�$�L�D�@�
O�P�P�:�:�"@rrc�v�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�NewTextTemplateTestCaser	c�:�tjd��|_yrrrs rrzNewTextTemplateTestCase.setUpzrrc�B�tj|j�yrrrs rrz NewTextTemplateTestCase.tearDown}rrc�z�td�}|jd|j�jd���y)Nz\{% escaped %}z
{% escaped %}r �rr#r$r%r&s  rr(z%NewTextTemplateTestCase.test_escaping�s5���0�1����������/�/��/�>�	@rc�z�td�}|jd|j�jd���y)Nz{# a comment #}r*r rkr&s  rr+z$NewTextTemplateTestCase.test_comment�s1���0�1������T�]�]�_�3�3�T�3�B�Crc�z�td�}|jd|j�jd���y)Nz\{# escaped comment #}z{# escaped comment #}r rkr&s  rr-z-NewTextTemplateTestCase.test_comment_escaping�s6���8�9�����0�����/�/��/�>�	@rc�~�td�}|jd|jd��jd���y)Nz&
{% if foo %}
  bar
{% end 'if foo' %}r/Fr0r rkr&s  rr2z*NewTextTemplateTestCase.test_end_with_args�s<��� ���	
����t�}�}��}�7�>�>��>�M�Nrc��djd�}t|d��}|jd|jdd��j	d���yr4)r;rr#r$r%r<s   rr>z+NewTextTemplateTestCase.test_latin1_encoded�r?rc��d}t|�}|jd|jdd��jd���yrArkr<s   rrBz*NewTextTemplateTestCase.test_unicode_input�rCrc��td�}|jd|jtd���j	d���y)Nz9Your items:

{% for item in items %}  * ${item}
{% end %}zYour items:

  * 0
  * 1
  * 2
rErFr �rr#r$rIr%r&s  rrJz)NewTextTemplateTestCase.test_empty_lines1�sH��� 
���
	
����

�]�]��q��]�"�)�)�4�)�8�	:rc��td�}|jd|jtd���j	d���y)Nz?Your items:

{% for item in items %}\
  * ${item}
{% end %}z$Your items:

  * 0
  * 1
  * 2
rErFr rrr&s  r�test_empty_lines1_with_crlfz3NewTextTemplateTestCase.test_empty_lines1_with_crlf�sI��� �
��	
�����]�]��q��]�
*�
1�
1�4�
1�
@�		Brc��td�}|jd|jtd���j	d���y)Nz:Your items:

{% for item in items %}  * ${item}

{% end %}z"Your items:

  * 0

  * 1

  * 2

rErFr rrr&s  rrLz)NewTextTemplateTestCase.test_empty_lines2�sH��� 
���	
����
�]�]��q��]�"�)�)�4�)�8�	:rc��td�}|jd|jtd���j	d���y)NzAYour items:

{% for item in items %}\
  * ${item}

{% end %}z*Your items:

  * 0

  * 1

  * 2

rErFr rrr&s  r�test_empty_lines2_with_crlfz3NewTextTemplateTestCase.test_empty_lines2_with_crlf�sH��� �
��	
����	
�
�
�E�!�H�
�%�,�,�d�,�;�	=rc��td�y)zw
        Verify that a code block with trailing space does not cause a syntax
        error (see ticket #127).
        z?
          {% python
            bar = 42
          $}
        N)rrs r�test_exec_with_trailing_spacez5NewTextTemplateTestCase.test_exec_with_trailing_space�s��
	��	
rc�z�td�}|jd|j�jd���y)NzQ{% python from datetime import timedelta %}
        ${timedelta(days=2)}
        z!
        2 days, 0:00:00
        r rkr&s  r�test_exec_importz(NewTextTemplateTestCase.test_exec_import�s=��� �
��	
����
�]�]�_�
#�
#�T�
#�
2�	4rc�z�td�}|jd|j�jd���y)NzW{% python
        def foo():
            return 42
        %}
        ${foo()}
        z
        42
        r rkr&s  r�
test_exec_defz%NewTextTemplateTestCase.test_exec_def�s=��� �
��	
����
�]�]�_�
#�
#�T�
#�
2�	4rc��ttjj|jd�d�}	|jdj
d��|j�ttjj|jd�d�}	|jdj
d��|j�t|jg�}|jdt��}|jd|j�jd�	��y#|j�wxYw#|j�wxYw)
NrNrO�IncludedrPrQzk----- Included data below this line -----
{% include tmpl1.txt %}
----- Included data above this line -----rRz\----- Included data below this line -----
Included
----- Included data above this line -----r �rTrUrVrWrrXr;rYrrZrr#r$r%r[s     rr_z$NewTextTemplateTestCase.test_include�s����R�W�W�\�\�$�,�,��<�d�C��	��K�K��*�*�7�3�4��K�K�M��R�W�W�\�\�$�,�,��<�d�C��	��K�K�-�-3�V�G�_�
>�
�K�K�M������/���{�{�;�O�{�<�����-�����/�/��/�>�	@��
�K�K�M��
�K�K�M�r`c��ttjj|jd�d�}	|jdj
d��|j�ttjj|jd�d�}	|jdj
d��|j�t|jg�}|jdt��}|jd|j�jd�	��y#|j�wxYw#|j�wxYw)
NrNrOrrPrQz�----- Included data below this line -----
    {% include ${'%s.txt' % ('tmpl1',)} %}
    ----- Included data above this line -----rRzd----- Included data below this line -----
    Included
    ----- Included data above this line -----r r�r[s     r�test_include_exprz)NewTextTemplateTestCase.test_include_exprs����b�g�g�l�l�4�<�<��=�t�D��
�
�[�[��+�+�G�4�
5�
�[�[�]��b�g�g�l�l�4�<�<��=�t�D��
�
�[�[�1�17����B��[�[�]� �$�,�,��0�����K�_��=��	
�	�	�1��-�-�/�0�0�$�0�?�
A���[�[�]���[�[�]�r`N)rarbrcrdrrr(r+r-r2r>rBrJrtrLrwryr{r}r_r�rerrrgrgwsc��-�>�$�@�
D�@�
O�P�P�:�B�:�"=� 	
�4�	4�@�,Arrgc�6�tj�}|jtjt
j��|jtjtd��|jtjtd��|S)N�test)
�unittest�	TestSuite�addTest�doctest�DocTestSuiterrb�	makeSuiterrg)�suites rr�r�'sf����� �E�	�M�M�'�&�&��'A�'A�B�C�	�M�M�(�$�$�%<�f�E�F�	�M�M�(�$�$�%<�f�E�F��Lr�__main__r�)�defaultTest)r�rUrrr��genshi.template.baser�genshi.template.loaderr�genshi.template.textrr�TestCaserrgr�ra�mainrerr�<module>r�so���	�
���4�1�A�[@�h�/�/�[@�|mA�h�/�/�mA�`��z���H�M�M�g�&�r