
    w:i&                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlmZmZmZ dZ G d dej                  Z G d	 d
ej                  Zd Zedk    r ej        d           dS dS )    N)Stream)DocType)MarkupTemplateTextTemplateNewTextTemplate)ConfigurationErrorMarkupTemplateEnginePluginTextTemplateEnginePluginzgenshi.template.testsc                   h    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )"MarkupTemplateEnginePluginTestCasec                    t                      }|                     d |j                   |                     d|j                   |                     d |j                   |                     g |j        j                   |                     d|j        j                   |                     d|j        j        j	                   d S )NhtmlT   )
r	   assertEqualdefault_encodingdefault_formatdefault_doctypeloadersearch_pathauto_reload_cachecapacityselfplugins     Y/var/www/html/trac/venv/lib/python3.11/site-packages/genshi/template/tests/test_plugin.pytest_init_no_optionsz7MarkupTemplateEnginePluginTestCase.test_init_no_options   s    +--v6777!6777v5666V]6777v}8999V]1:;;;;;    c                     t          dddd          }|                     ddg|j        j                   |                     d|j        j                   |                     d	|j        j        j                   d S 
Noff100z%/usr/share/tmpl:/usr/local/share/tmpl)zgenshi.auto_reloadgenshi.max_cache_sizezgenshi.search_pathoptionsz/usr/share/tmplz/usr/local/share/tmplFd   )r	   r   r   r   r   r   r   r   s     r   test_init_with_loader_optionsz@MarkupTemplateEnginePluginTestCase.test_init_with_loader_options)   s    +"'%*"I5
 5
   
 	+-DE2	4 	4 	4 9:::fm2;<<<<<r   c                 N    |                      t          t          ddi           d S )Nr#   thirtyr$   assertRaisesr   r	   r   s    r   !test_init_with_invalid_cache_sizezDMarkupTemplateEnginePluginTestCase.test_init_with_invalid_cache_size4   <    ,.H#:H"E 	 	G 	G 	G 	G 	Gr   c                     t          dddd          }|                     d|j                   |                     d|j                   |                     t          j        |j                   d S )Niso-8859-15xhtmlzxhtml-strict)genshi.default_encodinggenshi.default_formatgenshi.default_doctyper$   )r	   r   r   r   r   XHTMLr   r   s     r   test_init_with_output_optionsz@MarkupTemplateEnginePluginTestCase.test_init_with_output_options8   s~    +'4%,&45
 5
   
 	(?@@@&"7888(>?????r   c                 N    |                      t          t          ddi           d S )Nr3   foobarr$   r*   r,   s    r   $test_init_with_invalid_output_formatzGMarkupTemplateEnginePluginTestCase.test_init_with_invalid_output_formatB   r.   r   c                 N    |                      t          t          ddi           d S )Nr4   r8   r$   r*   r,   s    r   test_init_with_invalid_doctypezAMarkupTemplateEnginePluginTestCase.test_init_with_invalid_doctypeF   s<    ,.H#;X"F 	 	H 	H 	H 	H 	Hr   c                     t                      }|                    t          dz             }|                     dt          j                            |j                             t          |t                    sJ d S )N.templates.testz	test.html)
r	   load_templatePACKAGEr   ospathbasenamefilename
isinstancer   r   r   tmpls      r   test_load_template_from_filez?MarkupTemplateEnginePluginTestCase.test_load_template_from_fileJ   sj    +--##G.?$?@@bg&6&6t}&E&EFFF$///////r   c                     t                      }|                    d d          }|                     d |j                   t	          |t
                    sJ d S )Nz#<p>
          $message
        </p>template_string)r	   r>   r   rC   rD   r   rE   s      r   test_load_template_from_stringzAMarkupTemplateEnginePluginTestCase.test_load_template_from_stringP   sb    +--##D ;#   	t}---$///////r   c                     t                      }|                    t          dz             }|                    ddi|          }t	          |t
                    sJ d S Nr=   messageHello)r	   r>   r?   	transformrD   r   r   r   rF   streams       r   test_transform_with_loadz;MarkupTemplateEnginePluginTestCase.test_transform_with_loadX   s\    +--##G.?$?@@!!9g"6==&&)))))))r   c                     t                      }|                    ddit          dz             }t          |t                    sJ d S NrN   rO   r=   )r	   rP   r?   rD   r   r   r   rR   s      r   test_transform_without_loadz>MarkupTemplateEnginePluginTestCase.test_transform_without_load^   sN    +--!!9g"6"),="=? ?&&)))))))r   c                     t                      }|                    t          dz             }|                    ddi|          }|                     d|           d S )Nr=   rN   rO   templatez<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>Test</h1>
    <p>Hello</p>
  </body>
</html>r	   r>   r?   renderr   r   r   rF   outputs       r   test_renderz.MarkupTemplateEnginePluginTestCase.test_renderd   sl    +--##G.?$?@@	73dCC 	 		 		 		 		 		r   c                     t                      }|                    t          dz             }|                    ddid|          }|                     d|           d S )Nr=   rN   rO   r1   )formatrZ   a  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>Test</h1>
    <p>Hello</p>
  </body>
</html>r[   r]   s       r   test_render_with_formatz:MarkupTemplateEnginePluginTestCase.test_render_with_formats   sv    +--##G.?$?@@	73G(,  . . 	 		 		 		 		 		r   c                     t          ddi          }|                    t          dz             }|                    ddi|          }|                     d|           d S )	Nr4   html-strictr$   r=   rN   rO   rY   z<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>Test</h1>
    <p>Hello</p>
  </body>
</html>r[   r]   s       r   test_render_with_doctypez;MarkupTemplateEnginePluginTestCase.test_render_with_doctype   s    +$m5
    ##G.?$?@@	73dCC 	 		 		 		 		 		r   c                     t          ddi          }|                    t          dz             }|                    ddi|d          }|                     d	|           d S )
Nr4   rd   r$   z.templates.test_no_doctyperN   rO   T)rZ   fragmentzy<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>Test</h1>
    <p>Hello</p>
  </body>
</html>r[   r]   s       r   !test_render_fragment_with_doctypezDMarkupTemplateEnginePluginTestCase.test_render_fragment_with_doctype   s    +$m5
    ##G.J$JKK	73d(,  . .  	 	 	 	 	r   c                     t                      }|                    t          dz             }|                    ddi|          }|                     d|           d S )N.templates.functionssnippetz
<b>Foo</b>rY   z,<div>
False
bar
<b>Foo</b>
<b>Foo</b>
</div>r[   r]   s       r   test_helper_functionsz8MarkupTemplateEnginePluginTestCase.test_helper_functions   sl    +--##G.D$DEE	=9DII 

 	 	 	 	 	r   N)__name__
__module____qualname__r   r'   r-   r6   r9   r;   rG   rK   rS   rW   r_   rb   re   rh   rl    r   r   r   r      s       < < <	= 	= 	=G G G@ @ @G G GH H H0 0 00 0 0* * ** * *       "  "	 	 	 	 	r   r   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS ) TextTemplateEnginePluginTestCasec                 X   t                      }|                     d |j                   |                     d|j                   |                     g |j        j                   |                     d|j        j                   |                     d|j        j        j                   d S )NtextTr   )	r
   r   r   r   r   r   r   r   r   r   s     r   r   z5TextTemplateEnginePluginTestCase.test_init_no_options   s    )++v6777!6777V]6777v}8999V]1:;;;;;r   c                     t          dddd          }|                     ddg|j        j                   |                     d|j        j                   |                     d	|j        j        j                   d S r    )r
   r   r   r   r   r   r   r   s     r   r'   z>TextTemplateEnginePluginTestCase.test_init_with_loader_options   s    )"'%*"I3
 3
   
 	+-DE2	4 	4 	4 9:::fm2;<<<<<r   c                 `    t          ddi          }|                     d|j                   d S )Nr2   r0   r$   )r
   r   r   r   s     r   r6   z>TextTemplateEnginePluginTestCase.test_init_with_output_options   sA    )%}3
    	(?@@@@@r   c                    t          ddi          }|                     t          |j                   |                    t
          dz             }|                    ddi|          }|                     d|           d S )	Nzgenshi.new_text_syntaxyesr$   z.templates.new_syntaxfooTrY   bar)r
   r   r   template_classr>   r?   r\   r]   s       r   test_init_with_new_syntaxz:TextTemplateEnginePluginTestCase.test_init_with_new_syntax   s    )$e3
    	&*?@@@##G.E$EFFt}t<<'''''r   c                     t                      }|                    t          dz             }t          |t                    sJ |                     dt          j                            |j	                             d S )Nr=   ztest.txt)
r
   r>   r?   rD   r   r   r@   rA   rB   rC   rE   s      r   rG   z=TextTemplateEnginePluginTestCase.test_load_template_from_file   sj    )++##G.?$?@@$-----RW%5%5dm%D%DEEEEEr   c                     t                      }|                    d d          }|                     d |j                   t	          |t
                    sJ d S )Nz$messagerI   )r
   r>   r   rC   rD   r   rE   s      r   rK   z?TextTemplateEnginePluginTestCase.test_load_template_from_string   sY    )++##D*#EEt}---$-------r   c                     t                      }|                    ddit          dz             }t          |t                    sJ d S rU   )r
   rP   r?   rD   r   rV   s      r   rW   z<TextTemplateEnginePluginTestCase.test_transform_without_load   sN    )++!!9g"6"),="=? ?&&)))))))r   c                     t                      }|                    t          dz             }|                    ddi|          }t	          |t
                    sJ d S rM   )r
   r>   r?   rP   rD   r   rQ   s       r   rS   z9TextTemplateEnginePluginTestCase.test_transform_with_load   s\    )++##G.?$?@@!!9g"6==&&)))))))r   c                     t                      }|                    t          dz             }|                    ddi|          }|                     d|           d S )Nr=   rN   rO   rY   zTest
====

Hello
r
   r>   r?   r\   r   r]   s       r   r_   z,TextTemplateEnginePluginTestCase.test_render   sl    )++##G.?$?@@	73dCC  		 	 	 	 	r   c                     t                      }|                    t          dz             }|                    i |          }|                     d|           d S )Nrj   rY   z
False
bar
r   r]   s       r   rl   z6TextTemplateEnginePluginTestCase.test_helper_functions   se    )++##G.D$DEErD11 	 	 	 	 	r   N)rm   rn   ro   r   r'   r6   r|   rG   rK   rW   rS   r_   rl   rp   r   r   rr   rr      s        < < <	= 	= 	=A A A( ( (F F F. . .* * ** * *      r   rr   c                     t          j                    } |                     t           j                            t
                               |                     t           j                            t                               | S )N)unittest	TestSuiteaddTestdefaultTestLoaderloadTestsFromTestCaser   rr   )suites    r   r   r     s]      E	MM(,BBCeffggg	MM(,BBCcddeeeLr   __main__r   )defaultTest)doctestr@   r   genshi.corer   genshi.outputr   genshi.templater   r   r   genshi.template.pluginr   r	   r
   r?   TestCaser   rr   r   rm   mainrp   r   r   <module>r      sH    				        ! ! ! ! ! ! I I I I I I I I I I< < < < < < < < < < "Q Q Q Q Q): Q Q QhM M M M Mx'8 M M M`   zHMg&&&&&& r   