
                         0   d dl Z d dlZ G d d      Z G d de j                  e      Z G d de j                  e      Z G d d	e j                  e      Z G d
 de j                  e      Z G d de j                  e      Z	 G d de j                  e      Z
y)    Nc                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
DecoratorTestMixinc                 (     | j                   |fi |S N)	DECORATOR)selfmaxsizekwargss      9platform/gsutil/third_party/cachetools/tests/test_func.py	decoratorzDecoratorTestMixin.decorator   s    t~~g000    c                     | j                  d      d       }| j                  |j                         ddd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d      d       | j                  |j                         d	       | j                   |d
      d
       | j                  |j                         d       y )N   r	   c                     | S r    ns    r   <lambda>z3DecoratorTestMixin.test_decorator.<locals>.<lambda>       Qr   Fr	   typedr   r   r   r      r   r   r   r   r   r   r   r         ?)r   r   r   r   r   assertEqualcache_parameters
cache_infor   cacheds     r   test_decoratorz!DecoratorTestMixin.test_decorator
       **;7002E4RS**,l;A&**,l;A&**,l;c***,l;r   c                     | j                  d      d       }| j                  |j                         ddd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       |j	                          | j                  |j                         d       | j                   |d      d       | j                  |j                         d       y )	Nr   r   c                     | S r   r   r   s    r   r   z9DecoratorTestMixin.test_decorator_clear.<locals>.<lambda>   r   r   Fr   r   r   r   )r   r   r    r!   cache_clearr"   s     r   test_decorator_clearz'DecoratorTestMixin.test_decorator_clear   s    **;7002E4RS**,l;A&**,l;**,l;A&**,l;r   c                     | j                  d      d       }| j                  |j                         ddd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d      d       | j                  |j                         d	       | j                   |d
      d
       | j                  |j                         d       y )Nr   r   c                     | S r   r   r   s    r   r   z;DecoratorTestMixin.test_decorator_nocache.<locals>.<lambda>!   r   r   Fr   )r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   )r      r   r   r   r"   s     r   test_decorator_nocachez)DecoratorTestMixin.test_decorator_nocache    r%   r   c                     | j                  d       d       }| j                  |j                         d dd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d	      d	       | j                  |j                         d
       y )Nr   c                     | S r   r   r   s    r   r   z;DecoratorTestMixin.test_decorator_unbound.<locals>.<lambda>,   s    r   Fr   )r   r   Nr   r   )r   r   Nr   )r   r   Nr   r   )r   r   Nr   r   r"   s     r   test_decorator_unboundz)DecoratorTestMixin.test_decorator_unbound+   s    --k:002u4UV**,o>A&**,o>A&**,o>c***,o>r   c                 ~    | j                  dd      d       }| j                  |j                         ddd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d	      d	       | j                  |j                         d
       | j                   |d	      d	       | j                  |j                         d       y )Nr   Tr   c                     | S r   r   r   s    r   r   z9DecoratorTestMixin.test_decorator_typed.<locals>.<lambda>7   s    r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r"   s     r   test_decorator_typedz'DecoratorTestMixin.test_decorator_typed6   s   66{C002D4QR**,l;A&**,l;A&**,l;c***,l;c***,l;r   c                    | j                  d       }| j                  |j                         ddd       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d      d       | j                  |j                         d       | j                   |d	      d	       | j                  |j                         d
       y )Nc                     | S r   r   r   s    r   r   zADecoratorTestMixin.test_decorator_user_function.<locals>.<lambda>D       !r      Fr   )r   r   r7   r   r   )r   r   r7   r   )r   r   r7   r   r   )r   r   r7   r   r   r"   s     r   test_decorator_user_functionz/DecoratorTestMixin.test_decorator_user_functionC   s    ,002e4TU**,n=A&**,n=A&**,n=c***,n=r   c                     | j                  d        G fdd      }  |d               |d             | j                    |d             |d             y )Nc                     | S r   r   r   s    r   r   z?DecoratorTestMixin.test_decorator_needs_rlock.<locals>.<lambda>O   r6   r   c                   $    e Zd Zd Zd Z fdZy)FDecoratorTestMixin.test_decorator_needs_rlock.<locals>.RecursiveEqualsc                     || _         y r   
_use_cache)r   	use_caches     r   __init__zODecoratorTestMixin.test_decorator_needs_rlock.<locals>.RecursiveEquals.__init__R   s	    "+r   c                 ,    t        | j                        S r   )hashr?   )r   s    r   __hash__zODecoratorTestMixin.test_decorator_needs_rlock.<locals>.RecursiveEquals.__hash__U   s    DOO,,r   c                 ^    | j                   r |        | j                   |j                   k(  S r   r>   )r   otherr#   s     r   __eq__zMDecoratorTestMixin.test_decorator_needs_rlock.<locals>.RecursiveEquals.__eq__X   s(    ?? 4L%*:*:::r   N)__name__
__module____qualname__rA   rD   rG   )r#   s   r   RecursiveEqualsr<   Q   s    ,-;r   rK   FT)r   r   )r   rK   r#   s     @r   test_decorator_needs_rlockz-DecoratorTestMixin.test_decorator_needs_rlockN   sV    ,	; 	; 	u%&t$% 568MNr   N)rH   rI   rJ   r   r$   r)   r-   r0   r3   r8   rL   r   r   r   r   r      s+    1	<	<	<	?<	>Or   r   c                   D    e Zd Z eej
                  j                        Zy)FIFODecoratorTestN)rH   rI   rJ   staticmethod
cachetoolsfunc
fifo_cacher   r   r   r   rN   rN   f   s    Z__778Ir   rN   c                   D    e Zd Z eej
                  j                        Zy)LFUDecoratorTestN)rH   rI   rJ   rO   rP   rQ   	lfu_cacher   r   r   r   rT   rT   j       Z__667Ir   rT   c                   D    e Zd Z eej
                  j                        Zy)LRUDecoratorTestN)rH   rI   rJ   rO   rP   rQ   	lru_cacher   r   r   r   rX   rX   n   rV   r   rX   c                       e Zd Zd Zy)MRUDecoratorTestc                 :   dd l }|j                  d      5 }|j                  d       t        j                  j
                  |fi |}d d d        | j                  t              d       | j                  |d   j                  t               S # 1 sw Y   IxY w)Nr   T)recordalways)warningscatch_warningssimplefilterrP   rQ   	mru_cacheassertNotEquallenassertIscategoryDeprecationWarning)r   r	   r
   r_   wds         r   r   zMRUDecoratorTest.decorators   s    $$D$1Q!!(+))'<V<A 2 	CFA&admm%78 21s   2BBN)rH   rI   rJ   r   r   r   r   r[   r[   r   s    r   r[   c                   D    e Zd Z eej
                  j                        Zy)RRDecoratorTestN)rH   rI   rJ   rO   rP   rQ   rr_cacher   r   r   r   rk   rk   ~   s    Z__556Ir   rk   c                   D    e Zd Z eej
                  j                        Zy)TTLDecoratorTestN)rH   rI   rJ   rO   rP   rQ   	ttl_cacher   r   r   r   rn   rn      rV   r   rn   )unittestcachetools.funcrP   r   TestCaserN   rT   rX   r[   rk   rn   r   r   r   <module>rs      s     ]O ]O@9))+= 98x((*< 88x((*< 8	x((*< 	7h''); 78x((*< 8r   