o
    h                     @   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   i/var/www/html/construction_image-detection-poc/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