ó
:îÜW…  c           @   s†   d  d l  Z d  d l j j Z d  d l Z d  d l m Z d d
 d „  ƒ  YZ	 d e	 f d „  ƒ  YZ
 d e	 f d „  ƒ  YZ d	 „  Z d S(   iÿÿÿÿN(   t	   cacheutilt   BasicCacheAPITestc           B   s;   e  Z d Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s¢  |  j  j d d „  ƒ } d } | | k } | sÅ t j d | f d | | f ƒ i d t j ƒ  k sr t j | ƒ r t j | ƒ n d d 6t j | ƒ d 6} d i | d 6} t t j	 | ƒ ƒ ‚ n  d  } } |  j  j d d „  ƒ } d } | | k } | s”t j d | f d | | f ƒ i d t j ƒ  k sAt j | ƒ rPt j | ƒ n d d 6t j | ƒ d 6} d i | d 6} t t j	 | ƒ ƒ ‚ n  d  } } d  S(   NiÖÿÿÿc           S   s   d S(   Ni*   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   <lambda>   s    i*   s   ==s   %(py0)s == %(py3)st   valt   py0t   py3t    s   assert %(py5)st   py5c           S   s   d S(   Ni   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   	   s    (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   t   cachet
   getorbuildt
   @pytest_art   _call_reprcomparet   @py_builtinst   localst   _should_repr_global_namet	   _safereprt   AssertionErrort   _format_explanationt   None(   t   selfR   t   @py_assert2t   @py_assert1t   @py_format4t   @py_format6(    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_getorbuild   s        l   
   l   c         C   s   t  j j t d ƒ d  S(   Ns   self.cache._getentry(-23)(   t   pyt   testt   raisest   KeyError(   R   (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_cache_get_key_error   s    c         C   s?   |  j  j d d „  ƒ } |  j  j d ƒ t j j t d ƒ d  S(   Nid   c           S   s   d S(   Nid   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR      s    s   self.cache._getentry(100)(   R   R	   t   delentryR   R   R   R   (   R   R   (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_delentry_non_raising   s    c         C   s?   |  j  j d d „  ƒ } |  j  j d ƒ t j j t d ƒ d  S(   Nid   c           S   s   d S(   Nid   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR      s    s&   self.cache.delentry(100, raising=True)(   R   R	   R   R   R   R   R   (   R   R   (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_delentry_raising   s    c         C   s   |  j  j ƒ  d  S(   N(   R   t   clear(   R   (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt
   test_clear   s    N(	   t   __name__t
   __module__R   R   R   R   R   R    R"   (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR      s   				t   TestBuildcostAccessc           B   s#   e  Z e j d  d ƒ Z d „  Z RS(   t
   maxentriesi€   c            s
  t  j ƒ  } d g ‰  ‡  f d †  } | j t  d | ƒ xt | j ƒ D] ‰ | j ˆ ‡ f d †  ƒ } ˆ | k } | rAt j d f | f d f ˆ | f ƒ i d t j	 ƒ  k pÀ t j
 ˆ ƒ rÒ t j ˆ ƒ n d d 6d	 t j	 ƒ  k p÷ t j
 | ƒ r	t j | ƒ n d	 d
 6} d d i | d 6} t t j | ƒ ƒ ‚ n  t } qG Wx¤t | j ƒ D]“‰ | j } | ˆ t ƒ } | ˆ k }	 |	 ràt j d f |	 f d f | ˆ f ƒ i d t j	 ƒ  k pÑt j
 ˆ ƒ rãt j ˆ ƒ n d d 6d t j	 ƒ  k pt j
 | ƒ rt j | ƒ n d d 6t j | ƒ d
 6d t j	 ƒ  k pOt j
 ˆ ƒ rat j ˆ ƒ n d d 6d t j	 ƒ  k p†t j
 t ƒ r˜t j t ƒ n d d 6t j | ƒ d 6}
 d d i |
 d 6} t t j | ƒ ƒ ‚ n  t } } }	 q[Wt | j d ƒ } x.t | ƒ D] ‰ | j } | ˆ t ƒ } | ˆ k }	 |	 r—t j d f |	 f d f | ˆ f ƒ i d t j	 ƒ  k pˆt j
 ˆ ƒ ršt j ˆ ƒ n d d 6d t j	 ƒ  k p¿t j
 | ƒ rÑt j | ƒ n d d 6t j | ƒ d
 6d t j	 ƒ  k pt j
 ˆ ƒ rt j ˆ ƒ n d d 6d t j	 ƒ  k p=t j
 t ƒ rOt j t ƒ n d d 6t j | ƒ d 6}
 d d i |
 d 6} t t j | ƒ ƒ ‚ n  t } } }	 | j } | ˆ t ƒ } | ˆ k }	 |	 r$t j d f |	 f d f | ˆ f ƒ i d t j	 ƒ  k pt j
 ˆ ƒ r't j ˆ ƒ n d d 6d t j	 ƒ  k pLt j
 | ƒ r^t j | ƒ n d d 6t j | ƒ d
 6d t j	 ƒ  k p“t j
 ˆ ƒ r¥t j ˆ ƒ n d d 6d t j	 ƒ  k pÊt j
 t ƒ rÜt j t ƒ n d d 6t j | ƒ d 6}
 d d i |
 d 6} t t j | ƒ ƒ ‚ n  t } } }	 qW| j d d „  ƒ } d } | | k } | rt j d f | f d f | | f ƒ i d t j	 ƒ  k p©t j
 | ƒ r»t j | ƒ n d d 6t j | ƒ d 6} d d i | d 6} t t j | ƒ ƒ ‚ n  t } } x¡t | ƒ D]“‰ | j } | ˆ t ƒ } | ˆ k }	 |	 rŸt j d f |	 f d f | ˆ f ƒ i d t j	 ƒ  k pt j
 ˆ ƒ r¢t j ˆ ƒ n d d 6d t j	 ƒ  k pÇt j
 | ƒ rÙt j | ƒ n d d 6t j | ƒ d
 6d t j	 ƒ  k pt j
 ˆ ƒ r t j ˆ ƒ n d d 6d t j	 ƒ  k pEt j
 t ƒ rWt j t ƒ n d d 6t j | ƒ d 6}
 d d i |
 d 6} t t j | ƒ ƒ ‚ n  t } } }	 qW| j } d } | | t ƒ } d } | | k } | rî	t j d f | f d f | | f ƒ i d t j	 ƒ  k p-	t j
 | ƒ r?	t j | ƒ n d d 6t j | ƒ d
 6t j | ƒ d 6d t j	 ƒ  k p„	t j
 t ƒ r–	t j t ƒ n d d 6t j | ƒ d 6t j | ƒ d 6} d d  i | d! 6} t t j | ƒ ƒ ‚ n  t } } } } } d  S("   Ni    c              s   ˆ  d d ˆ  d <ˆ  d S(   Ni    i   (    (    (   t   l(    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   counter'   s    t   gettimec              s   ˆ  S(   N(    (    (   t   x(    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   ,   s    s   ==s   %(py0)s == %(py2)sR*   R   t   yt   py2R   s   assert %(py4)st   py4sY   %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.getorbuild
}(%(py3)s, %(py4)s)
} == %(py8)st   py8R   R   R   t   py6s   assert %(py10)st   py10i   iÿÿÿÿc           S   s   d S(   Ni*   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   5   s    i*   s   %(py0)s == %(py3)sR   s   assert %(py5)sR   sZ   %(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.getorbuild
}(%(py4)s, %(py5)s)
} == %(py10)st   py7s   assert %(py12)st   py12(   R    t   BuildcostAccessCachet   setattrt   rangeR&   R	   R
   R   R   R   R   R   R   R   R   t   int(   R   t   monkeypatchR   R(   R+   R   t   @py_format3t   @py_format5t   @py_assert5t   @py_assert7t   @py_format9t   @py_format11t   halfentriesR   R   R   R   t   @py_assert3t   @py_assert6t   @py_assert9t   @py_assert8t   @py_format13(    (   R'   R*   sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt    test_cache_works_somewhat_simple   sŒ    	  ™   
	    ÿ (   	    ÿ (   	    ÿ (      r   
	    ÿ (   	      Ù   (   R#   R$   R    R3   R   RD   (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR%      s   t	   TestAgingc           B   s/   e  Z d  Z e j d d d e ƒ Z d „  Z RS(   gš™™™™™¹?R&   i€   t
   maxsecondsc         C   s©   |  j  j d d „  ƒ t j j j ƒ  |  j d } xo t j j j ƒ  | k  r” y |  j  j d ƒ Wn t k
 rv Pn Xt j j j |  j d ƒ q6 Wt j	 j
 d ƒ d  S(   Ni   c           S   s   d S(   Ni   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   C   s    i
   g333333Ó?s!   waiting for cache eviction failed(   R   R	   R   t   stdt   timet   maxsecst	   _getentryR   t   sleepR   t   fail(   R   t   endtime(    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_cache_evictionB   s    (   R#   R$   RI   R    t
   AgingCacheR   RN   (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyRE   >   s   c             s†   d }  t  j d d d |  ƒ } x0 t | j ƒ D] ‰  | j ˆ  ‡  f d †  ƒ q. Wt j j j |  d ƒ | j | j d d „  ƒ d  S(	   Ngš™™™™™©?R&   i
   RF   c              s   ˆ  S(   N(    (    (   R*   (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   R   s    gš™™™™™ñ?i   c           S   s   d S(   Ni*   (    (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyR   T   s    (	   R    RO   R5   R&   R	   R   RG   RH   RK   (   RI   R   (    (   R*   sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   test_prune_lowestweightN   s    (    (   t   __builtin__R   t   _pytest.assertion.rewritet	   assertiont   rewriteR
   R   t   py._pathR    R   R%   RE   RP   (    (    (    sA   /home/ronny/Projects/pytest-dev/py/testing/path/test_cacheutil.pyt   <module>   s     "