B
    é¹`Bm  ã               @   s&  d dl Zd dlZd dlZd dlZd dlZd dlmZ ddlm	Z	m
Z
 G dd„ deƒZG dd„ deejƒZG d	d
„ d
ejƒZG dd„ deejƒZG dd„ deejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdd„ ZdS )é    N)Útestingé   )Útext_Ú	text_typec               @   s   e Zd Zdd„ Zdd„ ZdS )ÚBasec             C   s2   t  ¡ | _tj tj t¡¡}tj |d¡| _	d S )NÚfixtures)
r   ÚsetUpÚconfigÚosÚpathÚabspathÚdirnameÚ__file__ÚjoinÚtemplates_dir)ÚselfÚhere© r   úZ/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pyramid_mako/tests.pyr      s    
z
Base.setUpc             C   s   t  ¡  d S )N)r   ÚtearDown)r   r   r   r   r      s    zBase.tearDownN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s   r   c               @   s~   e Zd Zdd„ Zdd„ Zddd„Zdd	„ Zd
d„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestMakoRendererFactoryc             C   s   ddl m} |S )Nr   )ÚMakoRendererFactory)Úpyramid_makor   )r   r   r   r   r   Ú_getTargetClass   s    z'TestMakoRendererFactory._getTargetClassc             C   s   |   ¡ ƒ }||_|S )N)r   Úlookup)r   r   Úfactoryr   r   r   Ú_makeOne   s    
z TestMakoRendererFactory._makeOneNc             C   s    |d krt ƒ }|  |¡}||ƒS )N)ÚDummyLookupr   )r   Úinfor   r   r   r   r   Ú_callFUT$   s    
z TestMakoRendererFactory._callFUTc             K   s,   |d | j j| j  ¡ ddœ}| |¡ t|ƒS )NÚ )ÚnameÚpackageÚregistryÚsettingsÚtype)r	   r&   Zget_settingsÚupdateÚDummyRendererInfo)r   ÚspecÚkwÚoptsr   r   r   Ú_makeRendererInfo*   s    
z)TestMakoRendererFactory._makeRendererInfoc             C   s8   |   d¡}|  |¡}|  |jjd¡ |  |jd k¡ d S )Nzapp:moon-and-world.mak)r.   r"   ÚassertEqualÚtemplater   Ú
assertTrueÚdefname)r   r!   Úrendererr   r   r   Útest_asset_spec_filenames5   s    

z1TestMakoRendererFactory.test_asset_spec_filenamesc             C   s6   |   d¡}|  |¡}|  |jjd¡ |  |jd¡ d S )Nzapp:moon-and-world#def.makzapp:moon-and-world.makÚdef)r.   r"   r/   r0   r   r2   )r   r!   r3   r   r   r   Ú"test_asset_spec_filenames_with_def;   s    

z:TestMakoRendererFactory.test_asset_spec_filenames_with_defc             C   s8   |   d¡}|  |¡}|  |jjd¡ |  |jd k¡ d S )Nz*pyramid_mako.tests:fixtures/helloworld.mak)r.   r"   r/   r0   r   r1   r2   )r   r!   r3   r   r   r   Ú#test_asset_spec_subfolder_filenamesA   s    

z;TestMakoRendererFactory.test_asset_spec_subfolder_filenamesc             C   s6   |   d¡}|  |¡}|  |jjd¡ |  |jd¡ d S )Nz.pyramid_mako.tests:fixtures/helloworld#def.makz*pyramid_mako.tests:fixtures/helloworld.makr5   )r.   r"   r/   r0   r   r2   )r   r!   r3   r   r   r   Ú,test_asset_spec_subfolder_filenames_with_defI   s    

zDTestMakoRendererFactory.test_asset_spec_subfolder_filenames_with_defc             C   s8   |   d¡}|  |¡}|  |jjd¡ |  |jd k¡ d S )Nztemplates/moon-and-world.mak)r.   r"   r/   r0   r   r1   r2   )r   r!   r3   r   r   r   Útest_relative_filenamesQ   s    

z/TestMakoRendererFactory.test_relative_filenamesc             C   s6   |   d¡}|  |¡}|  |jjd¡ |  |jd¡ d S )Nz templates/moon-and-world#def.makztemplates/moon-and-world.makr5   )r.   r"   r/   r0   r   r2   )r   r!   r3   r   r   r   Ú test_relative_filenames_with_defW   s    

z8TestMakoRendererFactory.test_relative_filenames_with_defc             C   s8   |   d¡}|  |¡}|  |jjd¡ |  |jd k¡ d S )Nzmoon.and.world.mak)r.   r"   r/   r0   r   r1   r2   )r   r!   r3   r   r   r   Útest_multiple_dotted_filenames]   s    

z6TestMakoRendererFactory.test_multiple_dotted_filenamesc             C   s6   |   d¡}|  |¡}|  |jjd¡ |  |jd¡ d S )Nzmoon.and.world#def.makzmoon.and.world.makr5   )r.   r"   r/   r0   r   r2   )r   r!   r3   r   r   r   Ú'test_multiple_dotted_filenames_with_defc   s    

z?TestMakoRendererFactory.test_multiple_dotted_filenames_with_defc             C   s8   |   d¡}|  |¡}|  |jjd¡ |  |jd k¡ d S )Nzhello .world.mako)r.   r"   r/   r0   r   r1   r2   )r   r!   r3   r   r   r   Útest_space_dot_namei   s    

z+TestMakoRendererFactory.test_space_dot_namec             C   s6   |   d¡}|  |¡}|  |jjd¡ |  |jd¡ d S )Nzhello .world#comp.makozhello .world.makoÚcomp)r.   r"   r/   r0   r   r2   )r   r!   r3   r   r   r   Útest_space_dot_name_with_defo   s    

z4TestMakoRendererFactory.test_space_dot_name_with_def)N)r   r   r   r   r   r"   r.   r4   r6   r7   r8   r9   r:   r;   r<   r=   r?   r   r   r   r   r      s   
r   c               @   s   e Zd Zdd„ Zdd„ ZdS )Ú'TestIntegrationWithPreprocessorSettingsc             C   s8   t  ¡ | _dddddœ| _| j | j¡ | j d¡ d S )Nzpyramid_mako.tests:fixturesz*pyramid_mako.tests.dummy_mako_preprocessorÚtrueZGoodbye)zmako.directorieszmako.preprocessorz mako.preprocessor_wants_settingsÚreplace_Hellor   )r   r   r	   r'   Úadd_settingsÚinclude)r   r   r   r   r   v   s    

z-TestIntegrationWithPreprocessorSettings.setUpc             C   s6   ddl m} |di ƒ dd¡}|  | jd |k¡ d S )Nr   )Úrenderzhelloinherit.makúr#   rB   )Úpyramid.renderersrE   Úreplacer1   r'   )r   rE   Úrenderedr   r   r   Útest_with_preprocessor_settings   s    zGTestIntegrationWithPreprocessorSettings.test_with_preprocessor_settingsN)r   r   r   r   rJ   r   r   r   r   r@   u   s   r@   c               @   sê   e Zd Zd6dd„Zdd„ Zdd„ Zdd	„ Zd
d„ Ze 	d¡dd„ ƒZ
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Ze 	d¡d3d4„ ƒZd5S )7Ú Test_parse_options_from_settingsúmako.c             C   s   ddl m} |||| jjƒS )Nr   )Úparse_options_from_settings)r   rM   r	   Zmaybe_dotted)r   r'   Úsettings_prefixrM   r   r   r   r"   ‡   s    z)Test_parse_options_from_settings._callFUTc             C   s.   |   i ¡}|  |d g ¡ |  |d d¡ d S )NÚdirectoriesÚfilesystem_checksF)r"   r/   )r   Úresultr   r   r   Útest_no_directoriesŒ   s    
z4Test_parse_options_from_settings.test_no_directoriesc             C   s<   d| j i}|  |¡}|  |d | j g¡ |  |d d¡ d S )Nzmako.directoriesrO   rP   F)r   r"   r/   )r   r'   rQ   r   r   r   Útest_directories_path‘   s    

z6Test_parse_options_from_settings.test_directories_pathc             C   sF   d| j  d | j  d }d|i}|  |¡}|  |d | j gd ¡ d S )NÚ
zmako.directoriesrO   é   )r   r"   r/   )r   Útwicer'   rQ   r   r   r   Útest_composite_directories_path—   s    
z@Test_parse_options_from_settings.test_composite_directories_pathc             C   s>   | j d | j  }d|i}|  |¡}|  |d | j gd ¡ d S )Nú zmako.directoriesrO   rU   )r   r"   r/   )r   rV   r'   rQ   r   r   r   Ú&test_composite_directories_path_spaces   s    
zGTest_parse_options_from_settings.test_composite_directories_path_spacesÚntc             C   s\   dddgi}|   |¡}tj tjd j¡ d¡}|  |d tj 	|d¡tj 	|d¡g¡ d S )Nzmako.directoriesÚaÚbÚ__main__Ú.rO   )
r"   r
   r   r   ÚsysÚmodulesr   Úrstripr/   r   )r   r'   rQ   Úmodule_pathr   r   r   Útest_directories_list£   s    

z6Test_parse_options_from_settings.test_directories_listc             C   sD   d}| j |dœ}|  |¡}tj tj t¡d¡}|  |d |¡ d S )Nzpyramid_mako.tests:fixtures)zmako.directorieszmako.module_directoryr   Úmodule_directory)r   r"   r
   r   r   r   r   r/   )r   rd   r'   rQ   r   r   r   r   Ú%test_with_module_directory_asset_spec­   s    
zFTest_parse_options_from_settings.test_with_module_directory_asset_specc             C   s@   t j t j t¡d¡}| j|dœ}|  |¡}|  |d |¡ d S )Nr   )zmako.directorieszmako.module_directoryrd   )r
   r   r   r   r   r   r"   r/   )r   r   r'   rQ   r   r   r   Ú(test_with_module_directory_asset_abspathµ   s
    
zITest_parse_options_from_settings.test_with_module_directory_asset_abspathc             C   s*   | j ddœ}|  |¡}|  |d d¡ d S )Nzutf-16)zmako.directorieszmako.input_encodingZinput_encoding)r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_input_encoding¼   s    
z9Test_parse_options_from_settings.test_with_input_encodingc             C   s4   dd l }| jddœ}|  |¡}|  |d |j¡ d S )Nr   zpyramid_mako.tests)zmako.directorieszmako.error_handlerZerror_handler)Úpyramid_mako.testsr   r"   r/   Útests)r   r   r'   rQ   r   r   r   Útest_with_error_handlerÂ   s
    
z8Test_parse_options_from_settings.test_with_error_handlerc             C   s4   dd l }| jddœ}|  |¡}|  |d |j¡ d S )Nr   zpyramid_mako.tests)zmako.directorieszmako.preprocessorÚpreprocessor)rh   r   r"   r/   ri   )r   r   r'   rQ   r   r   r   Útest_with_preprocessorÉ   s
    
z7Test_parse_options_from_settings.test_with_preprocessorc             C   s`   ddl }| jdddœ}|  |¡}|  |d jd¡ | jdddœ}|  |¡}|  |d |j¡ dS )	z”
        first we check to ensure the name is replaced on true-ish value.
        otherwise we check it doesn't change on false-ish values.
        r   Nzpyramid_mako.testsrA   )zmako.directorieszmako.preprocessorz mako.preprocessor_wants_settingsrk   Zpreprocessor_injectorÚfalse)rh   r   r"   r/   r   ri   )r   r   r'   r3   Z	settings2Z	renderer2r   r   r   rJ   Ð   s    

z@Test_parse_options_from_settings.test_with_preprocessor_settingsc             C   s.   | j ddœ}|  |¡}|  |d ddg¡ d S )Nz
h
g

)zmako.directorieszmako.default_filtersÚdefault_filtersÚhÚg)r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_default_filtersç   s    
z:Test_parse_options_from_settings.test_with_default_filtersc             C   s2   | j ddgdœ}|  |¡}|  |d ddg¡ d S )Nro   rp   )zmako.directorieszmako.default_filtersrn   )r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_default_filters_listí   s    
z?Test_parse_options_from_settings.test_with_default_filters_listc             C   s.   | j ddœ}|  |¡}|  |d ddg¡ d S )Nz

one
two

)zmako.directorieszmako.importsÚimportsÚoneÚtwo)r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_importsó   s    
z2Test_parse_options_from_settings.test_with_importsc             C   s2   | j ddgdœ}|  |¡}|  |d ddg¡ d S )Nrt   ru   )zmako.directorieszmako.importsrs   )r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_imports_listù   s    
z7Test_parse_options_from_settings.test_with_imports_listc             C   s.   | j ddœ}|  |¡}|  |d ddg¡ d S )Nzone two
three four
)zmako.directorieszmako.importsrs   zone twoz
three four)r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_imports_str_listÿ   s    
z;Test_parse_options_from_settings.test_with_imports_str_listc             C   s.   | j ddœ}|  |¡}|  |d ddg¡ d S )Nz

one
two

)zmako.directorieszmako.future_importsÚfuture_importsrt   ru   )r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_future_imports  s    
z9Test_parse_options_from_settings.test_with_future_importsc             C   s2   | j ddgdœ}|  |¡}|  |d ddg¡ d S )Nrt   ru   )zmako.directorieszmako.future_importsry   )r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_future_imports_list  s    
z>Test_parse_options_from_settings.test_with_future_imports_listc             C   s.   | j ddœ}|  |¡}|  |d ddg¡ d S )Nzone two)zmako.directorieszmako.future_importsry   rt   ru   )r   r"   r/   )r   r'   rQ   r   r   r   Ú!test_with_future_imports_str_list  s    
zBTest_parse_options_from_settings.test_with_future_imports_str_listc             C   s*   | j ddœ}|  |¡}|  |d d¡ d S )NrA   )zmako.directorieszmako.strict_undefinedÚstrict_undefinedT)r   r"   r/   )r   r'   rQ   r   r   r   Útest_with_strict_undefined_true  s    
z@Test_parse_options_from_settings.test_with_strict_undefined_truec             C   s*   | j ddœ}|  |¡}|  |d d¡ d S )Nrm   )zmako.directorieszmako.strict_undefinedr}   F)r   r"   r/   )r   r'   rQ   r   r   r   Ú test_with_strict_undefined_false  s    
zATest_parse_options_from_settings.test_with_strict_undefined_falsec             C   s*   | j ddœ}|  |¡}|  |d d¡ d S )NT)zmako.directorieszpyramid.reload_templatesrP   )r   r"   r/   )r   r'   rQ   r   r   r   Útest_reload_templates_namespace#  s    
z@Test_parse_options_from_settings.test_reload_templates_namespacec             C   s*   | j ddœ}|  |¡}|  |d d¡ d S )NÚTrue)zmako.directorieszpyramid.reload_templatesrP   T)r   r"   r/   )r   r'   rQ   r   r   r   Ú$test_reload_templates_namespace_text)  s    
zETest_parse_options_from_settings.test_reload_templates_namespace_textc             C   s’   ddddœ}|   |¡}tj tjd j¡ d¡}|  |d tj 	|d¡tj 	|d	¡g¡ | j |d
d}|  |d tj 	|d¡tj 	|d¡g¡ d S )Nza

bzc

drA   )zmako.directorieszothermako.directorieszpyramid.reload_templatesr]   r^   rO   r[   r\   z
othermako.)rN   ÚcÚd)
r"   r
   r   r   r_   r`   r   ra   r/   r   )r   r'   rQ   rb   r   r   r   Ú)test_multiple_registration_different_name/  s    


zJTest_parse_options_from_settings.test_multiple_registration_different_nameN)rL   )r   r   r   r"   rR   rS   rW   rY   r   Zskip_onrc   re   rf   rg   rj   rl   rJ   rq   rr   rv   rw   rx   rz   r{   r|   r~   r   r€   r‚   r…   r   r   r   r   rK   †   s2   

rK   c               @   sL   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )ÚMakoLookupTemplateRendererTestsc             C   s   ddl m} |S )Nr   )ÚMakoLookupTemplateRenderer)r   r‡   )r   r‡   r   r   r   r   A  s    z/MakoLookupTemplateRendererTests._getTargetClassc             O   s   |   ¡ }|||ŽS )N)r   )r   Úargr,   Úklassr   r   r   r   E  s    z(MakoLookupTemplateRendererTests._makeOnec             C   sH   t ƒ }|  |dd d ¡}|i ddiƒ}|  t|tƒ¡ |  |tdƒ¡ d S )Nzpyramid_mako:test.makoÚsystemr   rQ   )r    r   r1   Ú
isinstancer   r/   r   )r   r   ÚinstancerQ   r   r   r   Ú	test_callI  s
    z)MakoLookupTemplateRendererTests.test_callc             C   sH   t ƒ }|  |dd d ¡}|i ddiƒ}|  t|tƒ¡ |  |tdƒ¡ d S )Nzpyramid_mako:test.makoÚcontextr   rQ   )r    r   r1   r‹   r   r/   r   )r   r   rŒ   rQ   r   r   r   Útest_call_with_system_contextP  s
    z=MakoLookupTemplateRendererTests.test_call_with_system_contextc             C   sH   t ƒ }|  |ddd ¡}|i ddiƒ}|  t|tƒ¡ |  |tdƒ¡ d S )Nzpyramid_mako:test.makor2   rŠ   r   rQ   )r    r   r1   r‹   r   r/   r   )r   r   rŒ   rQ   r   r   r   Útest_call_with_defnameX  s
    z6MakoLookupTemplateRendererTests.test_call_with_defnamec             C   s*   t ƒ }|  |dd d ¡}|  t|d i ¡ d S )Nzpyramid_mako:test.mako)r    r   ÚassertRaisesÚ
ValueError)r   r   rŒ   r   r   r   Útest_call_with_nondict_value_  s    z<MakoLookupTemplateRendererTests.test_call_with_nondict_valuec             C   s.   t ƒ }|  |dd d ¡}|  t|di fi ¡ d S )Nzpyramid_mako:test.makoÚtest)r    r   r‘   r’   )r   r   rŒ   r   r   r   Útest_call_with_tuple_valued  s    z:MakoLookupTemplateRendererTests.test_call_with_tuple_valuec          
   C   sp   ddl m} ttd}|  |dd d ¡}y|i i ƒ W n2 |k
rf } z|  d|jk¡ W d d }~X Y nX t‚d S )Nr   )ÚMakoRenderingException)Ú
render_exczpyramid_mako:test.makoÚNotImplementedError)r   r–   r    r˜   r   r1   ÚtextÚAssertionError)r   r–   r   rŒ   Úer   r   r   Útest_call_render_raisesi  s    
"z7MakoLookupTemplateRendererTests.test_call_render_raisesN)r   r   r   r   r   r   r   r   r“   r•   rœ   r   r   r   r   r†   @  s   r†   c               @   s„   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS ) ÚTestIntegrationWithDirectoriesc             C   s*   t  ¡ | _| j ddi¡ | j d¡ d S )Nzmako.directorieszpyramid_mako.tests:fixturesr   )r   r   r	   rC   rD   )r   r   r   r   r   u  s    
z$TestIntegrationWithDirectories.setUpc             C   s   t  ¡  d S )N)r   r   )r   r   r   r   r   {  s    z'TestIntegrationWithDirectories.tearDownc             C   s8   ddl m} |dddiƒ dd¡}|  |tdd	ƒ¡ d S )
Nr   )rE   zhelloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_render~  s    z*TestIntegrationWithDirectories.test_renderc             C   s8   ddl m} |dddiƒ dd¡}|  |tdd	ƒ¡ d S )
Nr   )rE   zhelloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_render_from_fsƒ  s    z2TestIntegrationWithDirectories.test_render_from_fsc             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zhelloinherit.makrF   r#   zLayout
Hello World!
)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_render_inheritanceˆ  s    z6TestIntegrationWithDirectories.test_render_inheritancec             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zhello_inherit_pkg.makrF   r#   zLayout
Hello World!

)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Ú test_render_inheritance_pkg_spec  s    z?TestIntegrationWithDirectories.test_render_inheritance_pkg_specc             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zhellocompo.makrF   r#   z
Namespace
Hello 
World!

)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_render_namespace’  s    z4TestIntegrationWithDirectories.test_render_namespacec             C   s:   ddl m} |dddiƒ}|  |j dd¡tdd	ƒ¡ d S )
Nr   )Úrender_to_responsezhelloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r£   r/   ÚubodyrH   r   )r   r£   rQ   r   r   r   Útest_render_to_response—  s    z6TestIntegrationWithDirectories.test_render_to_responsec             C   s:   ddl m} |dddiƒ}|  |j dd¡tdd	ƒ¡ d S )
Nr   )r£   z*pyramid_mako.tests:fixtures/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r£   r/   r¤   rH   r   )r   r£   rQ   r   r   r   Ú test_render_to_response_pkg_spec  s
    z?TestIntegrationWithDirectories.test_render_to_response_pkg_specc             C   s8   ddl m} |dddiƒ dd¡}|  |tdd	ƒ¡ d S )
Nr   )rE   z/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_render_with_abs_path¤  s    z8TestIntegrationWithDirectories.test_render_with_abs_pathc             C   s8   ddl m} |dƒ}|  |j ¡  dd¡tddƒ¡ d S )Nr   )Úget_rendererzhelloworld.makrF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r¨   r/   r0   Úrender_unicoderH   r   )r   r¨   rQ   r   r   r   Útest_get_renderer©  s
    z0TestIntegrationWithDirectories.test_get_rendererc             C   s,   ddl m} ddlm} |  ||di ¡ d S )Nr   )rE   )ÚTemplateLookupExceptionzhelloworld_not_here.mak)rG   rE   Úmako.exceptionsr«   r‘   )r   rE   r«   r   r   r   Útest_template_not_found°  s    z6TestIntegrationWithDirectories.test_template_not_foundc             C   s6   ddl m} |dddiƒ dd¡}|  |tdƒ¡ d S )	Nr   )rE   znonminimal.makr$   z<b>fred</b>rF   r#   z Hello, &lt;b&gt;fred&lt;/b&gt;!
)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   Útest_template_default_escaping¶  s    z=TestIntegrationWithDirectories.test_template_default_escapingc             C   sV   ddl m} | j ddi¡ | jjddd |dd	d
iƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zfoo.directorieszpyramid_mako.tests:fixturesz.foozfoo.)rN   znonminimal.foor$   z<b>fred</b>rF   r#   z Hello, &lt;b&gt;fred&lt;/b&gt;!
)rG   rE   r	   rC   Úadd_mako_rendererrH   r/   r   )r   rE   rQ   r   r   r   Útest_add_mako_renderer¼  s    z5TestIntegrationWithDirectories.test_add_mako_rendererc             C   sx   ddl m} tjdd}| d¡ |jddd | d	d
i¡ | ¡  |dddiƒ dd¡}|  	|t
dƒ¡ | ¡  d S )Nr   )rE   F)Z
autocommitr   z.foozfoo.)rN   zfoo.directorieszpyramid_mako.tests:fixturesznonminimal.foor$   z<b>fred</b>rF   r#   z Hello, &lt;b&gt;fred&lt;/b&gt;!
)rG   rE   r   r   rD   r¯   rC   ÚcommitrH   r/   r   Úend)r   rE   r	   rQ   r   r   r   Ú&test_add_mako_renderer_before_settingsÅ  s    
zETestIntegrationWithDirectories.test_add_mako_renderer_before_settingsN)r   r   r   r   r   rž   rŸ   r    r¡   r¢   r¥   r¦   r§   rª   r­   r®   r°   r³   r   r   r   r   r   t  s   	r   c               @   s„   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS ) ÚTestIntegrationNoDirectoriesc             C   s   t  ¡ | _| j d¡ d S )Nr   )r   r   r	   rD   )r   r   r   r   r   Ó  s    
z"TestIntegrationNoDirectories.setUpc             C   s   t  ¡  d S )N)r   r   )r   r   r   r   r   ×  s    z%TestIntegrationNoDirectories.tearDownc             C   s8   ddl m} |dddiƒ dd¡}|  |tdd	ƒ¡ d S )
Nr   )rE   zfixtures/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   rž   Ú  s    z(TestIntegrationNoDirectories.test_renderc             C   s8   ddl m} |dddiƒ dd¡}|  |tdd	ƒ¡ d S )
Nr   )rE   zfixtures/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   rŸ   ß  s    z0TestIntegrationNoDirectories.test_render_from_fsc             C   s,   ddl m} ddlm} |  ||di ¡ d S )Nr   )rE   )r«   z-pyramid_mako:fixtures/helloworld_not_here.mak)rG   rE   r¬   r«   r‘   )r   rE   r«   r   r   r   Útest_render_notfoundä  s    z1TestIntegrationNoDirectories.test_render_notfoundc             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zfixtures/helloinherit.makrF   r#   zLayout
Hello World!
)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   r    ê  s    z4TestIntegrationNoDirectories.test_render_inheritancec             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zfixtures/hello_inherit_pkg.makrF   r#   zLayout
Hello World!

)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   r¡   ï  s    z=TestIntegrationNoDirectories.test_render_inheritance_pkg_specc             C   s2   ddl m} |di ƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zfixtures/hellocompo.makrF   r#   z
Namespace
Hello 
World!

)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   r¢   ô  s    z2TestIntegrationNoDirectories.test_render_namespacec             C   s:   ddl m} |dddiƒ}|  |j dd¡tdd	ƒ¡ d S )
Nr   )r£   zfixtures/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r£   r/   r¤   rH   r   )r   r£   rQ   r   r   r   r¥   ù  s    z4TestIntegrationNoDirectories.test_render_to_responsec             C   s:   ddl m} |dddiƒ}|  |j dd¡tdd	ƒ¡ d S )
Nr   )r£   z*pyramid_mako.tests:fixtures/helloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r£   r/   r¤   rH   r   )r   r£   rQ   r   r   r   r¦   ÿ  s
    z=TestIntegrationNoDirectories.test_render_to_response_pkg_specc             C   sh   ddl m} tj tj t¡¡}tj |d¡}tj |d¡}||ddiƒ dd¡}|  	|t
d	d
ƒ¡ d S )Nr   )rE   r   zhelloworld.makr[   r   rF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   rE   r
   r   r   r   r   r   rH   r/   r   )r   rE   r   r   r0   rQ   r   r   r   r§     s    z6TestIntegrationNoDirectories.test_render_with_abs_pathc             C   s8   ddl m} |dƒ}|  |j ¡  dd¡tddƒ¡ d S )Nr   )r¨   zfixtures/helloworld.makrF   r#   u   
Hello fÃ¶Ã¶
zutf-8)rG   r¨   r/   r0   r©   rH   r   )r   r¨   rQ   r   r   r   rª     s
    z.TestIntegrationNoDirectories.test_get_rendererc             C   s,   ddl m} ddlm} |  ||di ¡ d S )Nr   )rE   )r«   z fixtures/helloworld_not_here.mak)rG   rE   r¬   r«   r‘   )r   rE   r«   r   r   r   r­     s    z4TestIntegrationNoDirectories.test_template_not_foundc             C   s6   ddl m} |dddiƒ dd¡}|  |tdƒ¡ d S )	Nr   )rE   zfixtures/nonminimal.makr$   z<b>fred</b>rF   r#   z Hello, &lt;b&gt;fred&lt;/b&gt;!
)rG   rE   rH   r/   r   )r   rE   rQ   r   r   r   r®     s    z;TestIntegrationNoDirectories.test_template_default_escapingc             C   s|   ddl m} | j ddi¡ | jjddd |dd	d
iƒ dd¡}|  |tdƒ¡ |dd	d
iƒ dd¡}|  |tdƒ¡ d S )Nr   )rE   zfoo.directorieszpyramid_mako.tests:fixturesz.foozfoo.)rN   znonminimal.foor$   z<b>fred</b>rF   r#   z Hello, &lt;b&gt;fred&lt;/b&gt;!
zfixtures/nonminimal.mak)rG   rE   r	   rC   r¯   rH   r/   r   )r   rE   rQ   r   r   r   r°   !  s    z3TestIntegrationNoDirectories.test_add_mako_rendererN)r   r   r   r   r   rž   rŸ   rµ   r    r¡   r¢   r¥   r¦   r§   rª   r­   r®   r°   r   r   r   r   r´   Ò  s   r´   c               @   s|   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestPkgResourceTemplateLookupc             K   s   ddl m} |f |ŽS )Nr   )ÚPkgResourceTemplateLookup)r   r·   )r   r,   r·   r   r   r   r   .  s    z&TestPkgResourceTemplateLookup._makeOnec             C   s"   dd l }tj tj |jj¡d¡S )Nr   r   )rh   r
   r   r   r   ri   r   )r   r   r   r   r   Úget_fixturedir2  s    z,TestPkgResourceTemplateLookup.get_fixturedirc             C   s$   |   ¡ }| dd ¡}|  |d¡ d S )Nr[   z/a)r   Ú
adjust_urir/   )r   ÚinstrQ   r   r   r   Útest_adjust_uri_not_asset_spec7  s    z<TestPkgResourceTemplateLookup.test_adjust_uri_not_asset_specc             C   s$   |   ¡ }| dd ¡}|  |d¡ d S )Nza:b)r   r¹   r/   )r   rº   rQ   r   r   r   Útest_adjust_uri_asset_spec<  s    z8TestPkgResourceTemplateLookup.test_adjust_uri_asset_specc             C   s$   |   ¡ }| dd ¡}|  |d¡ d S )Nza$bza:b)r   r¹   r/   )r   rº   rQ   r   r   r   Ú3test_adjust_uri_asset_spec_with_modified_asset_specA  s    zQTestPkgResourceTemplateLookup.test_adjust_uri_asset_spec_with_modified_asset_specc             C   s$   |   ¡ }| dd¡}|  |d¡ d S )Nrƒ   za:bza:c)r   r¹   r/   )r   rº   rQ   r   r   r   Ú9test_adjust_uri_not_asset_spec_with_relativeto_asset_specF  s    zWTestPkgResourceTemplateLookup.test_adjust_uri_not_asset_spec_with_relativeto_asset_specc             C   s$   |   ¡ }| dd¡}|  |d¡ d S )Nrƒ   za$bza:c)r   r¹   r/   )r   rº   rQ   r   r   r   ÚBtest_adjust_uri_not_asset_spec_with_relativeto_modified_asset_specK  s    z`TestPkgResourceTemplateLookup.test_adjust_uri_not_asset_spec_with_relativeto_modified_asset_specc             C   s$   |   ¡ }| dd¡}|  |d¡ d S )Nr\   z../az../b)r   r¹   r/   )r   rº   rQ   r   r   r   Ú=test_adjust_uri_not_asset_spec_with_relativeto_not_asset_specP  s    z[TestPkgResourceTemplateLookup.test_adjust_uri_not_asset_spec_with_relativeto_not_asset_specc             C   s$   |   ¡ }| dd¡}|  |d¡ d S )Nz/cza:b)r   r¹   r/   )r   rº   rQ   r   r   r   Ú=test_adjust_uri_not_asset_spec_abs_with_relativeto_asset_specU  s    z[TestPkgResourceTemplateLookup.test_adjust_uri_not_asset_spec_abs_with_relativeto_asset_specc             C   s$   |   ¡ }| dd¡}|  |d¡ d S )Nza:bz/c)r   r¹   r/   )r   rº   rQ   r   r   r   Ú=test_adjust_uri_asset_spec_with_relativeto_not_asset_spec_absZ  s    z[TestPkgResourceTemplateLookup.test_adjust_uri_asset_spec_with_relativeto_not_asset_spec_absc             C   s2   |   ¡ }| j|gd}| d¡}|  |d k¡ d S )N)rO   zhelloworld.mak)r¸   r   Úget_templateÚassertFalse)r   Ú
fixturedirrº   rQ   r   r   r   Ú test_get_template_not_asset_spec_  s    
z>TestPkgResourceTemplateLookup.test_get_template_not_asset_specc             C   s(   | j dd}| d¡}|  |d k¡ d S )NT)rP   z*pyramid_mako.tests:fixtures/helloworld.mak)r   rÃ   rÄ   )r   rº   rQ   r   r   r   Ú3test_get_template_asset_spec_with_filesystem_checkse  s    zQTestPkgResourceTemplateLookup.test_get_template_asset_spec_with_filesystem_checksc          
   C   sF   t  ¡ }z(| j|d}| d¡}|  |d k¡ W d tj|dd X d S )N)rd   z*pyramid_mako.tests:fixtures/helloworld.makT)Úignore_errors)ÚtempfileÚmkdtempr   rÃ   rÄ   ÚshutilÚrmtree)r   Ztmpdirrº   rQ   r   r   r   Ú,test_get_template_asset_spec_with_module_dirk  s    zJTestPkgResourceTemplateLookup.test_get_template_asset_spec_with_module_dirc             C   s8   ddl m} |  ¡ }| jd|gd}|  ||jd¡ d S )Nr   )ÚTopLevelLookupExceptionT)rP   rO   z(pyramid_mako.tests:fixtures/notthere.mak)r¬   rÎ   r¸   r   r‘   rÃ   )r   rÎ   rÅ   rº   r   r   r   Ú$test_get_template_asset_spec_missingu  s
    
zBTestPkgResourceTemplateLookup.test_get_template_asset_spec_missingN)r   r   r   r   r¸   r»   r¼   r½   r¾   r¿   rÀ   rÁ   rÂ   rÆ   rÇ   rÍ   rÏ   r   r   r   r   r¶   -  s   
r¶   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestMakoRenderingExceptionc             C   s   ddl m} ||ƒS )Nr   )r–   )r   r–   )r   r™   r–   r   r   r   r   }  s    z#TestMakoRenderingException._makeOnec             C   s.   |   d¡}|  t|ƒd¡ |  t|ƒd¡ d S )Nr™   )r   r/   ÚstrÚrepr)r   Úexcr   r   r   Útest_repr_and_str  s    
z,TestMakoRenderingException.test_repr_and_strN)r   r   r   r   rÔ   r   r   r   r   rÐ   |  s   rÐ   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )r    Tc             O   s   || _ || _d S )N)Údt_kwÚdt_args)r   Úargsr,   r   r   r   Ú__init__‰  s    zDummyLookup.__init__c             C   s   t |f| jž| jŽS )N)ÚDummyTemplaterÖ   rÕ   )r   r   r   r   r   rÃ     s    zDummyLookup.get_templateN)r   r   r   rO   rØ   rÃ   r   r   r   r   r    †  s   r    c               @   s&   e Zd Zddd„Zdd„ Zdd„ ZdS )	rÙ   Nc             C   s   || _ || _d S )N)r   r—   )r   r   r—   r   r   r   rØ   ‘  s    zDummyTemplate.__init__c             C   s
   || _ | S )N)Zdeffed)r   r   r   r   r   Úget_def•  s    zDummyTemplate.get_defc             K   s   | j r| j ‚|| _tdƒS )NrQ   )r—   Úvaluesr   )r   rÛ   r   r   r   r©   ™  s    zDummyTemplate.render_unicode)NN)r   r   r   rØ   rÚ   r©   r   r   r   r   rÙ     s   
rÙ   c               @   s   e Zd Zdd„ ZdS )r*   c             C   s   | j  |¡ d S )N)Ú__dict__r)   )r   r,   r   r   r   rØ      s    zDummyRendererInfo.__init__N)r   r   r   rØ   r   r   r   r   r*   Ÿ  s   r*   c             C   s   |   d| dd¡¡} | S )NZHellorB   r#   )rH   Úget)r0   r'   r   r   r   Údummy_mako_preprocessor£  s    rÞ   )Úos.pathr
   rË   r_   rÉ   ZunittestZpyramidr   Úcompatr   r   Úobjectr   ZTestCaser   r@   rK   r†   r   r´   r¶   rÐ   r    rÙ   r*   rÞ   r   r   r   r   Ú<module>   s(   	[ ;4^[O

