
                              S SK r S SKrS SKr " S S5      r " S S5      r " S S\ R
                  \5      r " S S	\ R
                  \5      r " S
 S\ R
                  5      rg)    Nc                   &    \ rS rSrS rS rS rSrg)CountedLock   c                     SU l         g Nr   countselfs    ;platform/gsutil/third_party/cachetools/tests/test_cached.py__init__CountedLock.__init__   s	    
    c                 .    U =R                   S-  sl         g )N   r   r
   s    r   	__enter__CountedLock.__enter__   s    

a
r   c                     g N )r   excs     r   __exit__CountedLock.__exit__   s    r   r   N)__name__
__module____qualname____firstlineno__r   r   r   __static_attributes__r   r   r   r   r      s    r   r   c                   P    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rSrg)DecoratorTestMixin   c                     [         er   )NotImplementedErrorr   minsizes     r   cacheDecoratorTestMixin.cache   s    !!r   c                     [        U S5      (       a!  U =R                  S-  sl        U R                  $ SU l        U R                  $ )Nr	   r   r   )hasattrr	   r   argskwargss      r   funcDecoratorTestMixin.func   s;    4!!JJ!OJ zz DJzzr   c                    U R                  S5      n[        R                  " U5      " U R                  5      nU R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R	                  U" S5      S5        U R	                  [        U5      S5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R	                  U" S5      S5        U R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        g )N   r   r         ?)
r&   
cachetoolscachedr-   assertEquallenassertInkeyshashkeyassertNotInr   r&   wrappers      r   test_decorator!DecoratorTestMixin.test_decorator   s   

1##E*4995UQ'Q'UQ'joo--a0%8003U;005u=Q'UQ'joo--a0%8joo--a0%8joo--c2E:Q'UQ'q)UQ'q)UQ'r   c                 $   U R                  S5      n[        R                  R                  n[        R                  " XS9" U R
                  5      nU R                  [        U5      S5        U R                  U" S5      S5        U R                  [        U5      S5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  U" S5      S5        U R                  [        U5      S5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  U" S5      S5        U R                  [        U5      S5        U R                  U" S5      S5        U R                  [        U5      S5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  [        R                  R                  S5      U5        U R                  U" S5      S5        U R                  [        U5      S5        g )N   )keyr   r   r1   r0   )
r&   r2   r7   typedkeyr3   r-   r4   r5   r6   r9   )r   r&   r@   r;   s       r   test_decorator_typed'DecoratorTestMixin.test_decorator_typed7   s   

1oo&&##E3DII>UQ'Q'UQ'joo..q15911!4e<11#6>Q'UQ'joo..q159joo..q15911#6>Q'UQ'q)UQ'joo..q159joo..q159joo..s3U;q)UQ'r   c                    U R                  S5      n[        5       n[        R                  " XS9" U R                  5      nU R                  [        U5      S5        U R                  U" S5      S5        U R                  UR                  S5        U R                  U" S5      S5        U R                  UR                  S5        U R                  U" S5      S5        U R                  UR                  S5        g )Nr0   lockr   r         r&   r   r2   r3   r-   r4   r5   r	   r   r&   rF   r;   s       r   test_decorator_lock&DecoratorTestMixin.test_decorator_lockU   s    

1}##E5dii@UQ'Q'Q'Q'Q'Q'Q'r   c                 8   U R                  S5      n[        R                  " U5      " U R                  5      nU R	                  UR
                  U R                  5        U R	                  [        U5      S5        U R	                  UR                  S5      S5        U R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        g Nr0   r   r   )r&   r2   r3   r-   r4   __wrapped__r5   r:   s      r   test_decorator_wrapped)DecoratorTestMixin.test_decorator_wrappedb   s    

1##E*4995,,dii8UQ',,Q/3UQ'Q'UQ'Q'UQ'r   c                 J   U R                  S5      n[        R                  " U5      " U R                  5      nU R	                  UR                   U5        U R	                  UR
                  [        R                  R                  5        U R	                  UR                  S 5        g )Nr0   )	r&   r2   r3   r-   assertIs	cache_keyr7   r8   
cache_lockr:   s      r   test_decorator_attributes,DecoratorTestMixin.test_decorator_attributesp   sl    

1##E*4995gmmU+g'')@)@Ag(($/r   c                 Z   U R                  S5      n[        5       n[        R                  " XS9" U R                  5      nU R                  UR                   U5        U R                  UR                  [        R                  R                  5        U R                  UR                  U5        g )Nr0   rE   )
r&   r   r2   r3   r-   rS   rT   r7   r8   rU   rJ   s       r   test_decorator_attributes_lock1DecoratorTestMixin.test_decorator_attributes_lockx   ss    

1}##E5dii@gmmU+g'')@)@Ag(($/r   c                 .   U R                  S5      n[        R                  " U5      " U R                  5      nU R	                  U" S5      S5        U R	                  [        U5      S5        UR                  5         U R	                  [        U5      S5        g rN   )r&   r2   r3   r-   r4   r5   cache_clearr:   s      r   test_decorator_clear'DecoratorTestMixin.test_decorator_clear   sp    

1##E*4995Q'UQ'UQ'r   c                    U R                  S5      n[        5       n[        R                  " XS9" U R                  5      nU R                  U" S5      S5        U R                  [        U5      S5        U R                  UR                  S5        UR                  5         U R                  [        U5      S5        U R                  UR                  S5        g )Nr0   rE   r   r   r?   )	r&   r   r2   r3   r-   r4   r5   r	   r\   rJ   s       r   test_decorator_clear_lock,DecoratorTestMixin.test_decorator_clear_lock   s    

1}##E5dii@Q'UQ'Q'UQ'Q'r   r   N)r   r   r   r   r&   r-   r<   rB   rK   rP   rV   rY   r]   r`   r   r   r   r   r    r       s4    "(4(<((00(	(r   r    c                   2    \ rS rSrS rS rS rS rS rSr	g)	CacheWrapperTest   c                 *    [         R                  " US9$ )N)maxsize)r2   Cacher$   s     r   r&   CacheWrapperTest.cache   s    00r   c                    U R                  S5      n[        R                  " USS9" U R                  5      nU R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S	5        UR                  5         U R	                  [        U5      S5        U R	                  UR                  5       S5        g )
Nr0   Tinfo)r   r   r0   r   r   )r   r   r0   r   r   )r   r0   r0   r0   )r   r0   r0   r0   r&   r2   r3   r-   r4   
cache_infor\   r5   r:   s      r   test_decorator_info$CacheWrapperTest.test_decorator_info   s   

1##E5dii@++-|<Q'++-|<Q'++-|<Q'++-|<UQ'++-|<r   c                    U R                  S5      n[        R                  " U5      " U R                  5      nU R	                  [        U5      S5        U R	                  U" S5      S5        U R	                  [        U5      S5        g r   )r&   r2   r3   r-   r4   r5   r:   s      r   test_zero_size_cache_decorator/CacheWrapperTest.test_zero_size_cache_decorator   sd    

1##E*4995UQ'Q'UQ'r   c                 V   U R                  S5      n[        5       n[        R                  " XS9" U R                  5      nU R                  [        U5      S5        U R                  U" S5      S5        U R                  [        U5      S5        U R                  UR                  S5        g )Nr   rE   r0   rI   rJ   s       r   #test_zero_size_cache_decorator_lock4CacheWrapperTest.test_zero_size_cache_decorator_lock   s    

1}##E5dii@UQ'Q'UQ'Q'r   c                     U R                  S5      n[        R                  " USS9" U R                  5      nU R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S5        g )Nr   Trj   r   r   r   r   r   r   r   r   )r&   r2   r3   r-   r4   rm   r:   s      r   #test_zero_size_cache_decorator_info4CacheWrapperTest.test_zero_size_cache_decorator_info   sp    

1##E5dii@++-|<Q'++-|<r   r   N)
r   r   r   r   r&   rn   rq   rt   ry   r   r   r   r   rc   rc      s    1=((=r   rc   c                        \ rS rSrS rS rSrg)DictWrapperTest   c                     [        5       $ r   )dictr$   s     r   r&   DictWrapperTest.cache   s	    vr   c                    U R                  S5      n[        R                  " USS9" U R                  5      nU R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S5        U R	                  U" S5      S5        U R	                  UR                  5       S	5        UR                  5         U R	                  [        U5      S5        U R	                  UR                  5       S5        g )
Nr0   Trj   )r   r   Nr   r   )r   r   Nr   r   )r   r0   Nr0   )r   r0   Nr0   rl   r:   s      r   rn   #DictWrapperTest.test_decorator_info   s   

1##E5dii@++-?Q'++-?Q'++-?Q'++-?UQ'++-?r   r   N)r   r   r   r   r&   rn   r   r   r   r   r|   r|      s    @r   r|   c                   2    \ rS rSrS rS rS rS rS rSr	g)	NoneWrapperTest   c                 :    U[        UR                  5       5      -   $ r   )tupleitemsr*   s      r   r-   NoneWrapperTest.func   s    eFLLN+++r   c                     [         R                  " S 5      " U R                  5      nU R                  U" S5      S5        U R                  U" S5      S5        U R                  U" SSS9S5        g )Nr   r   r   r   bar)foo)r   )r   r   )r2   r3   r-   r4   r   r;   s     r   r<   NoneWrapperTest.test_decorator   s[    ##D)$))4T*T*.0CDr   c                 (   [         R                  " S 5      " U R                  5      nU R                  UR                  S 5        U R                  UR
                  [         R                  R                  5        U R                  UR                  S 5        g r   )	r2   r3   r-   rS   r&   rT   r7   r8   rU   r   s     r   rV   )NoneWrapperTest.test_decorator_attributes   s_    ##D)$))4gmmT*g'')@)@Ag(($/r   c                 p    [         R                  " S 5      " U R                  5      nUR                  5         g r   )r2   r3   r-   r\   r   s     r   r]   $NoneWrapperTest.test_decorator_clear   s'    ##D)$))4r   c                    [         R                  " S SS9" U R                  5      nU R                  UR	                  5       S5        U R                  U" S5      S5        U R                  UR	                  5       S5        U R                  U" S5      S5        U R                  UR	                  5       S	5        UR                  5         U R                  UR	                  5       S5        g )
NTrj   rw   r   r   rx   r   r   )r   r0   r   r   )r2   r3   r-   r4   rm   r\   r   s     r   rn   #NoneWrapperTest.test_decorator_info   s    ##Dt4TYY?++-|<T*++-|<T*++-|<++-|<r   r   N)
r   r   r   r   r-   r<   rV   r]   rn   r   r   r   r   r   r      s    ,E0
	=r   r   )	unittestr2   cachetools.keysr   r    TestCaserc   r|   r   r   r   r   <module>r      sd       @( @(F*=x((*< *=Z@h''); @& =h''  =r   