o
    ‹ågä  ã                   @   sr   d dl Z d dlmZ d dlmZ d dlmZ ddlmZ ddlmZ G dd	„ d	ƒZ	G d
d„ deƒZ
ededƒ dS )é    N)Ú	CacheImpl)Úregister_plugin)ÚTemplateé   )Úeq_)Úconfigc                   @   sT   e Zd Zdd„ Zdd„ Z			ddd„Z			dd	d
„Z			ddd„Zdd„ ZdS )ÚTemplateTestc                 K   s"   |   |¡}td||tjdœ|¤ŽS )N)ÚuriÚfilenameÚmodule_directory© )Ú
_file_pathr   r   Úmodule_base)Úselfr
   ÚkwÚfilepathr   r   úQ/var/www/html/flaskapp/venv/lib/python3.10/site-packages/mako/testing/fixtures.pyÚ_file_template   s   
ýüzTemplateTest._file_templatec                 C   sH   t j |¡\}}t j tj|d | ¡}t j |¡r|S t j tj|¡S )NÚ_py3k)ÚosÚpathÚsplitextÚjoinr   Útemplate_baseÚexists)r   r
   ÚnameÚextÚ	py3k_pathr   r   r   r      s
   zTemplateTest._file_pathNTc                 K   s*   | j |fi |¤Ž}| j|||||d� d S )N©ÚfiltersÚunicode_Útemplate_args)r   Ú_do_test)r   r
   Úexpectedr   r    r!   r   Út1r   r   r   Ú_do_file_test   ó   	
ûzTemplateTest._do_file_testc                 K   s*   t dd|i|¤Ž}| j|||||d� d S )NÚtextr   r   )r   r"   )r   Úsourcer#   r   r    r!   r   r$   r   r   r   Ú_do_memory_test.   r&   zTemplateTest._do_memory_testc                 C   sL   |d u ri }|r|j di |¤Ž}n|jdi |¤Ž}|r||ƒ}t||ƒ d S ©Nr   )Úrender_unicodeÚrenderr   )r   Útemplater#   r   r!   r    Úoutputr   r   r   r"   @   s   zTemplateTest._do_testc                    s:   d|› d�}d|› d�d|› d�f}t ‡ fdd„|D ƒƒS )Nz&#39;zlocal variable z referenced before assignmentzcannot access local variable z where it is not associatedc                 3   s   � | ]}|ˆ v V  qd S ©Nr   )Ú.0Úmsg©Úrendered_outputr   r   Ú	<genexpr>[   s   € z=TemplateTest.indicates_unbound_local_error.<locals>.<genexpr>)Úany)r   r3   Úunbound_varÚvarÚ
error_msgsr   r2   r   Úindicates_unbound_local_errorS   s
   

üz*TemplateTest.indicates_unbound_local_error)NTN)NNT)	Ú__name__Ú
__module__Ú__qualname__r   r   r%   r)   r"   r9   r   r   r   r   r   
   s     	
ú
ú
úr   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚPlainCacheImplzTSimple memory cache impl so that tests which
    use caching can run without beaker.c                 C   s   || _ i | _d S r/   )ÚcacheÚdata)r   r>   r   r   r   Ú__init__b   s   
zPlainCacheImpl.__init__c                 K   s0   || j v r
| j | S |di |¤Ž | j |< }|S r*   ©r?   )r   ÚkeyÚcreation_functionr   r?   r   r   r   Úget_or_createf   s   

zPlainCacheImpl.get_or_createc                 K   s   || j |< d S r/   rA   )r   rB   Úvaluer   r   r   r   Úputm   s   zPlainCacheImpl.putc                 K   s
   | j | S r/   rA   ©r   rB   r   r   r   r   Úgetp   s   
zPlainCacheImpl.getc                 K   s   | j |= d S r/   rA   rG   r   r   r   Ú
invalidates   s   zPlainCacheImpl.invalidateN)	r:   r;   r<   Ú__doc__r@   rD   rF   rH   rI   r   r   r   r   r=   ^   s    r=   Úplain)r   Ú
mako.cacher   r   Úmako.templater   Ú
assertionsr   r   r   r=   r:   r   r   r   r   Ú<module>   s    T