B
    d                 @   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   b/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/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|}| 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text)r   r   r   )r   r   )r   sourcer   r   r   r   r   r   r   r   r   _do_memory_test.   s    	zTemplateTest._do_memory_testc             C   sD   |d kri }|r|j f |}n|jf |}|r6||}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   | ]}| kV  qd S )Nr   ).0msg)rendered_outputr   r   	<genexpr>[   s    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   r,   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 )N)cachedata)r   r1   r   r   r   __init__b   s    zPlainCacheImpl.__init__c             K   s0   || j kr| j | S |f | | j |< }|S d S )N)r2   )r   keyZcreation_functionr   r2   r   r   r   get_or_createf   s    

zPlainCacheImpl.get_or_createc             K   s   || j |< d S )N)r2   )r   r4   valuer   r   r   r   putm   s    zPlainCacheImpl.putc             K   s
   | j | S )N)r2   )r   r4   r   r   r   r   getp   s    zPlainCacheImpl.getc             K   s   | j |= d S )N)r2   )r   r4   r   r   r   r   
invalidates   s    zPlainCacheImpl.invalidateN)	r-   r.   r/   __doc__r3   r5   r7   r8   r9   r   r   r   r   r0   ^   s   r0   plain)r   Z
mako.cacher   r   Zmako.templater   Z
assertionsr   r   r   r0   r-   r   r   r   r   <module>   s   T