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/template/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

!�bSI�@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
Gdd�dej�Zdd�Z
ed	kr?ejdd
�dSdS)�N)�TEXT)�TemplateLoader)�MarkupTemplatec@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.S)/�TemplateLoaderTestCasezTests for the template loader.cCstjdd�|_dS)N�markup_test)�suffix)�tempfile�mkdtemp�dirname��self�r
�>/usr/lib/python3/dist-packages/genshi/template/tests/loader.py�setUpszTemplateLoaderTestCase.setUpcCst�|j�dS�N)�shutil�rmtreer
rr
r
r�tearDownszTemplateLoaderTestCase.tearDowncCst�}|�g|j�dSr)r�assertEqual�search_path�r�loaderr
r
r�test_search_path_empty"sz-TemplateLoaderTestCase.test_search_path_emptycCs t|j�}|�|jg|j�dSr)rr
rrrr
r
r�test_search_path_as_string&s
z1TemplateLoaderTestCase.test_search_path_as_stringcCs�ttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wt|jg�}|�d�}|�	d|�
�jdd��dS�N�
tmpl1.html�w�<div>Included</div>�
tmpl2.html�t<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="tmpl1.html" />
            </html>�<<html>
              <div>Included</div>
            </html>��encoding��open�os�path�joinr
�write�closer�loadr�generate�render�r�file1�file2r�tmplr
r
r�test_relative_include_samedir*s
�z4TemplateLoaderTestCase.test_relative_include_samedircCs�t�tj�|jd��ttj�|jdd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wt|jg�}|�	d�}|�
d|��jdd��dS)	N�subrrrrzx<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="sub/tmpl1.html" />
            </html>r r!)
r%�mkdirr&r'r
r$r(r)rr*rr+r,r-r
r
r�test_relative_include_subdir?s
�z3TemplateLoaderTestCase.test_relative_include_subdircCs�ttj�|jd�d�}z|�d�W|��n|��wt�tj�|jd��ttj�|jdd�d�}z|�d�W|��n|��wt|jg�}|�	d�}|�
d|��jdd	��dS)
Nrrrr2rzw<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="../tmpl1.html" />
            </html>�sub/tmpl2.htmlr r!�
r$r%r&r'r
r(r)r3rr*rr+r,r-r
r
r�test_relative_include_parentdirUs
�z6TemplateLoaderTestCase.test_relative_include_parentdircCs�ttj�|jd�d�}z|�d�W|��n|��wt�tj�|jd��ttj�|jdd�d�}z|�d�W|��n|��wttj�|jdd�d�}z|�d�W|��n|��wt|jg�}|�	d�}|�
d	|��jdd
��dS)Nrrz<div>Included tmpl1.html</div>r2z"<div>Included sub/tmpl1.html</div>rrr5zK<html>
              <div>Included sub/tmpl1.html</div>
            </html>r!r6�rr.r/�file3rr0r
r
r� test_relative_include_samesubdirks$
�z7TemplateLoaderTestCase.test_relative_include_samesubdircCs�ttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wt�}|�tj�|jd��}|�	d|�
�jdd��dSrr#r-r
r
r�)test_relative_include_without_search_path�s�z@TemplateLoaderTestCase.test_relative_include_without_search_pathcCs�ttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wtdtj�|jd�d�}|�d|�	�j
dd��dSr�r$r%r&r'r
r(r)rrr+r,�rr.r/r0r
r
r�$test_relative_include_without_loader�s��z;TemplateLoaderTestCase.test_relative_include_without_loadercCs�ttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wtdtj�|jd�d�}|�d|�	�j
dd��dS)	Nrrrrr)�filenamer r!r<r=r
r
r�-test_relative_include_without_loader_relative�s��zDTemplateLoaderTestCase.test_relative_include_without_loader_relativecCs�ttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wt�}|�tj�|jd��}|�	d|�
�jdd	��dS)
Nrrrrzr<div xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="tmpl1.html" />
            </div>�
tmpl3.html�t<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="tmpl2.html" />
            </html>zc<html>
              <div>
              <div>Included</div>
            </div>
            </html>r!r#r8r
r
r�0test_relative_include_without_search_path_nested�s"�zGTemplateLoaderTestCase.test_relative_include_without_search_path_nestedcCsnttj�|jd�d�}z|�d�W|��n|��wt|jg�}tdd|d�}|�	d|�
�jdd��dS)	Nrrrzo<html xmlns:xi="http://www.w3.org/2001/XInclude">
          <xi:include href="../tmpl1.html" />
        </html>zsubdir/tmpl2.html)r?rz4<html>
          <div>Included</div>
        </html>r!)r$r%r&r'r
r(r)rrrr+r,)rr.r�tmpl2r
r
r�,test_relative_include_from_inmemory_template�s��zCTemplateLoaderTestCase.test_relative_include_from_inmemory_templatec	Csttj�|jd�d�}z|�d�W|��n|��wt�tj�|jd��ttj�|jdd�d�}z|�d�W|��n|��wttj�|jdd�d�}z|�d�W|��n|��wt�}|�	tj�
tj�|jdd���}|�d|��j
dd	��dS)
Nrrrr2�<div>Included from sub</div>rr�E<html>
              <div>Included from sub</div>
            </html>r!�r$r%r&r'r
r(r)r3rr*�abspathrr+r,r8r
r
r�)test_relative_absolute_template_preferred�s(��z@TemplateLoaderTestCase.test_relative_absolute_template_preferredc	Cs�ttj�|jd�d�}z|�d�W|��n|��wt�tj�|jd��ttj�|jdd�d�}z|�d|j�W|��n|��wt�}|�	tj�
tj�|jdd���}|�d|��j
dd��dS)	Nrrrr2rzw<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="%s/tmpl1.html" />
            </html>r r!rHr-r
r
r�test_absolute_includes$���z,TemplateLoaderTestCase.test_absolute_includecCstj�|jd�}t�|�ttj�|d�d�}z|�d�W|��n|��wttj�|d�d�}z|�d�W|��n|��wtj�|jd�}t�|�ttj�|d�d�}z|�d�W|��n|��wt|�}|�	tj�|d��}|�
d	|��jdd
��d|j
vs�J�dS)N�absrrrBrz!<div>Included from abspath.</div>�
searchpathz$<div>Included from searchpath.</div>zM<html>
              <div>Included from searchpath.</div>
            </html>r!)r%r&r'r
r3r$r(r)rr*rr+r,�_cache)rrIr.r/rMr9r�tmpl1r
r
r�test_abspath_caching+s,

�z+TemplateLoaderTestCase.test_abspath_cachingcCspttj�|jd�d�}z|�d�W|��n|��wttj�|jd�d�}z|�d�W|��n|��wt�tj�|jd��ttj�|jdd�d�}z|�d�W|��n|��wttj�|jdd�d�}z|�d�W|��n|��wt�}|�	tj�|jd��}|�
d|��jdd	��|�	tj�|jdd��}|�
d
|��jdd	��d|j
vs�J�dS)NrrrBrrr2rFr r!rG)r$r%r&r'r
r(r)r3rr*rr+r,rN)rr.r/r9�file4rrOrDr
r
r�0test_abspath_include_caching_without_search_pathKs6��zGTemplateLoaderTestCase.test_abspath_include_caching_without_search_pathcCs\ttj�|jd�d�}z|�d�d��W|��n|��wt|jgdd�}|�	d�dS)N�	tmpl.html�wb�
<div>ö</div>�
iso-8859-1��default_encoding�
r$r%r&r'r
r(�encoder)rr*�r�frr
r
r�test_load_with_default_encodingtsz6TemplateLoaderTestCase.test_load_with_default_encodingcCs`ttj�|jd�d�}z|�d�d��W|��n|��wt|jgdd�}|j	ddd�dS)NrSrTrUrVzutf-8rWr!rYr[r
r
r� test_load_with_explicit_encoding}sz7TemplateLoaderTestCase.test_load_with_explicit_encodingcCs�ttj�|jd�d�}z|�d�W|��n|��wdd�}t|jg|d�}|�d�}|�	d|�
�jdd��|�d�}|�	d|�
�jdd��dS)	NrSrz5<html>
              <p>Hello</p>
            </html>cSsdd�}|j�d|�dS)NcssD�|D]\}}}|tur|��rd�||��g�}|||fVqdS)Nz, )r�stripr'�lower)�stream�ctxt�kind�data�posr
r
r�	my_filter�s��zZTemplateLoaderTestCase.test_load_with_callback.<locals>.template_loaded.<locals>.my_filterr)�filters�insert)�templaterfr
r
r�template_loaded�szGTemplateLoaderTestCase.test_load_with_callback.<locals>.template_loaded)�callbackz<<html>
              <p>Hello, hello</p>
            </html>r!r#)r�fileobjrjrr0r
r
r�test_load_with_callback�s
�
�z.TemplateLoaderTestCase.test_load_with_callbackc	Cs0tj�|jd�}t�|�ttj�|d�d�}z|�d�W|��n|��wtj�|jdd�}t�|�ttj�|d�d�}z|�d�W|��n|��wtj�|jdd�}t�|�ttj�|d	�d�}z|�d
�W|��n|��wt	|t	j
||d�g�}|�d�}|�d
|�
�jdd��dS)a
        Test prefix delegation with the following layout:
        
        templates/foo.html
        sub1/templates/tmpl1.html
        sub2/templates/tmpl2.html
        
        Where sub1 and sub2 are prefixes, and both tmpl1.html and tmpl2.html
        incldue foo.html.
        �	templates�foo.htmlr�<div>Included foo</div>�sub1rz<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="../foo.html" /> from sub1
            </html>�sub2r�<div>tmpl2</div>�rqrr�sub1/tmpl1.htmlzJ<html>
              <div>Included foo</div> from sub1
            </html>Nr!�r%r&r'r
r3r$r(r)�makedirsr�prefixedr*rr+r,)	r�dir1r.�dir2r/�dir3r9rr0r
r
r�%test_prefix_delegation_to_directories�s4



�
�z<TemplateLoaderTestCase.test_prefix_delegation_to_directoriesc
Csxtj�|jd�}t�|�ttj�|d�d�}z|�d�W|��n|��wtj�|jdd�}t�|�ttj�|d�d�}z|�d�W|��n|��wttj�|d�d�}z|�d	�W|��n|��wtj�|jddd
�}t�|�ttj�|d�d�}z|�d�W|��n|��wt	|t	j
tj�|�tj�|�d
�g�}|�d�}	|�d|	�
�jdd��dS)a"
        Test prefix delegation with the following layout:
        
        templates/foo.html
        sub1/templates/tmpl1.html
        sub1/templates/tmpl2.html
        sub1/templates/bar/tmpl3.html
        
        Where sub1 is a prefix, and tmpl1.html includes all the others.
        rnrorrprqrz�<html xmlns:xi="http://www.w3.org/2001/XInclude">
              <xi:include href="../foo.html" /> from sub1
              <xi:include href="tmpl2.html" /> from sub1
              <xi:include href="bar/tmpl3.html" /> from sub1
            </html>rrs�barrAz<div>bar/tmpl3</div>rtruz�<html>
              <div>Included foo</div> from sub1
              <div>tmpl2</div> from sub1
              <div>bar/tmpl3</div> from sub1
            </html>Nr!rv)
rryr.rzr/r9r{rQrr0r
r
r�2test_prefix_delegation_to_directories_with_subdirs�s<





�
�zITemplateLoaderTestCase.test_prefix_delegation_to_directories_with_subdirsN)�__name__�
__module__�__qualname__�__doc__rrrrr1r4r7r:r;r>r@rCrErJrKrPrRr]r^rmr|r~r
r
r
rrs0 )		.rcCs0t��}|�t�tj��|�t�td��|S)N�test)	�unittest�	TestSuite�addTest�doctest�DocTestSuiterr��	makeSuiter)�suiter
r
rr�
sr��__main__)�defaultTest)r�r%rrr��genshi.corer�genshi.template.loaderr�genshi.template.markupr�TestCaserr�r�mainr
r
r
r�<module>s 
t�

https://t.me/RX1948 - 2025