a
    e	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                   @   sB   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f ||tjd|S )N)urifilenameZmodule_directory)
_file_pathr   r   Zmodule_base)selfr
   kwfilepath r   X/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/testing/fixtures.py_file_template   s    
zTemplateTest._file_templatec                 C   sH   t j|\}}t jtj|d | }t j|r8|S t jtj|S )NZ_py3k)ospathsplitextjoinr   Ztemplate_baseexists)r   r
   nameextZ	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   s    	zTemplateTest._do_file_testc                 K   s*   t f d|i|}| j|||||d d S )Ntextr   )r   r   )r   sourcer   r   r   r   r   r   r   r   r   _do_memory_test.   s    	zTemplateTest._do_memory_testc                 C   sL   |d u ri }|r"|j f i |}n|jf i |}|r>||}t|| d S N)Z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 r$   r   ).0msgrendered_outputr   r   	<genexpr>[       z=TemplateTest.indicates_unbound_local_error.<locals>.<genexpr>)any)r   r+   Zunbound_varvarZ
error_msgsr   r*   r   indicates_unbound_local_errorS   s
    

z*TemplateTest.indicates_unbound_local_error)NTN)NTN)NNT)	__name__
__module____qualname__r   r   r    r#   r   r0   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   r5   r   r   r   __init__b   s    zPlainCacheImpl.__init__c                 K   s4   || j v r| j | S |f i | | j |< }|S d S r$   r6   )r   keyZcreation_functionr   r6   r   r   r   get_or_createf   s    

zPlainCacheImpl.get_or_createc                 K   s   || j |< d S r$   r8   )r   r9   valuer   r   r   r   putm   s    zPlainCacheImpl.putc                 K   s
   | j | S r$   r8   r   r9   r   r   r   r   getp   s    zPlainCacheImpl.getc                 K   s   | j |= d S r$   r8   r=   r   r   r   
invalidates   s    zPlainCacheImpl.invalidateN)	r1   r2   r3   __doc__r7   r:   r<   r>   r?   r   r   r   r   r4   ^   s   r4   plain)r   Z
mako.cacher   r   Zmako.templater   Z
assertionsr   r   r   r4   r1   r   r   r   r   <module>   s   T