ó
ŠwÛjc           @   s"  d  Z  d d l Z d d l Z d d l Z d d l m Z e j d ƒ e j d d e ƒZ e j d d e ƒd e j	 f d	 „  ƒ  YZ
 d
 e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ e d „ Z e d k re d e ƒ n  d S(   s{   Test script for the bsddb C module by Roger E. Masse
   Adapted to unittest format and expanded scope by Raymond Hettinger
iÿÿÿÿN(   t   test_supportt   _bsddbt   bsddbt
   deprecatedt   dbhasht	   TestBSDDBc           B   s  e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   cc         C   s†   |  j  d |  j |  j d d ƒ|  _ t d d d d d d	 d
 d d d d d ƒ |  _ x* |  j j ƒ  D] \ } } | |  j | <qe Wd  S(   Ni    t	   cachesizei €  t   qt   Guidot   wt   vant   et   Rossumt   rt   inventedt   tt   Pythont   yt    (   t
   openmethodt   fnamet   openflagt   ft   dictt   dt	   iteritems(   t   selft   kt   v(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   setUp   s    %0c         C   s\   |  j  j ƒ  |  j  j ƒ  |  j d  k r- d  Sy t j |  j ƒ Wn t j k
 rW n Xd  S(   N(   R   t   synct   closeR   t   Nonet   ost   removet   error(   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   tearDown   s    c         C   s;   x4 |  j  j ƒ  D]# \ } } |  j |  j | | ƒ q Wd  S(   N(   R   R   t   assertEqualR   (   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_getitem#   s    c         C   s&   |  j  t |  j ƒ t |  j ƒ ƒ d  S(   N(   R&   t   lenR   R   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_len'   s    c         C   sZ   d |  j  d <|  j |  j  d d ƒ |  j d |  j  j ƒ  ƒ |  j d |  j  j ƒ  ƒ d  S(   Nt
   discoveredR   (   R   R&   t   assertInt   keyst   values(   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_change*   s    c         C   st   |  j  |  j ƒ |  j j ƒ  |  j d |  j d ƒ |  _ x4 |  j j ƒ  D]# \ } } |  j |  j | | ƒ qI Wd  S(   Ni    R
   (   t   assertIsNotNoneR   R   R    R   R   R   R&   (   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_close_and_reopen0   s
    c         C   s    |  j  t | ƒ t | ƒ ƒ d  S(   N(   R&   t   set(   R   t   seqn1t   seqn2(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   assertSetEquals7   s    c         C   sÎ   |  j  } |  j } |  j | | ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ d  S(   N(	   R   R   R4   R,   R-   t   itemst   iterkeyst
   itervaluesR   (   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_mapping_iteration_methods:   s    		c         C   sÏ   t  |  j ƒ } x: y! | j ƒ  } d | |  j | <Wq t k
 rG Pq Xq Wt |  j ƒ } t  |  j ƒ } xD y+ | j ƒ  } d | |  j | <| d 8} Wqm t k
 r¬ Pqm Xqm W|  j | d ƒ |  j ƒ  d  S(   Ns	   modified i   i    (   t   iterR   t   nextt   StopIterationR(   R   R&   R8   (   R   t   dit   keyt
   loops_leftt   fi(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt    test_iter_while_modifying_valuesE   s$    		c            sB   ‡  f d †  } ˆ  j  t | ƒ ‡  f d †  } ˆ  j  t | ƒ d  S(   Nc             sJ   t  ˆ  j ƒ }  x4 y |  j ƒ  d ˆ  j d <Wq t k
 rA Pq Xq Wd  S(   Nt   SPAMt   newkey(   R9   R   R:   R;   (   R<   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   DictIterAbort_   s    
c             sJ   t  ˆ  j ƒ }  x4 y |  j ƒ  d ˆ  j d <Wq t k
 rA Pq Xq Wd  S(   NRA   RB   (   R9   R   R:   R;   (   R?   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   DbIterAborti   s    
(   t   assertRaisest   RuntimeError(   R   RC   RD   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_iter_abort_on_changed_size^   s    c            sB   ‡  f d †  } ˆ  j  t | ƒ ‡  f d †  } ˆ  j  t | ƒ d  S(   Nc             sJ   ˆ  j  j ƒ  }  x4 y |  j ƒ  d ˆ  j  d <Wq t k
 rA Pq Xq Wd  S(   NRA   RB   (   R   R   R:   R;   (   R<   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   DictIteritemsAbortt   s    
c             sO   ˆ  j  j ƒ  }  x9 y  |  j ƒ  \ } } ˆ  j  | =Wq t k
 rF Pq Xq Wd  S(   N(   R   R   R:   R;   (   R?   R=   t   value(   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   DbIteritemsAbort~   s    (   RE   RF   (   R   RH   RJ   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt$   test_iteritems_abort_on_changed_sizes   s    c         C   sÛ   |  j  j ƒ  } x@ y' | j ƒ  \ } } d | |  j  | <Wq t k
 rM Pq Xq Wt |  j ƒ } |  j j ƒ  } xJ y1 | j ƒ  \ } } d | |  j | <| d 8} Wqs t k
 r¸ Pqs Xqs W|  j | d ƒ |  j ƒ  d  S(   Ns	   modified i   i    (   R   R   R:   R;   R(   R   R&   R8   (   R   R<   R   R   R>   R?   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt%   test_iteritems_while_modifying_valuesˆ   s$    		c         C   sh   |  j  j ƒ  g } x6 t d t |  j  ƒ ƒ D] } | j |  j  j ƒ  ƒ q+ W|  j | |  j j ƒ  ƒ d  S(   Ni   (	   R   t   firstt   xrangeR(   t   appendR:   R4   R   R5   (   R   R5   t   i(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_first_next_looping¡   s    c         C   sh   |  j  j ƒ  g } x6 t d t |  j  ƒ ƒ D] } | j |  j  j ƒ  ƒ q+ W|  j | |  j j ƒ  ƒ d  S(   Ni   (	   R   t   lastRN   R(   RO   t   previousR4   R   R5   (   R   R5   RP   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_previous_last_looping§   s    c         C   sm   |  j  t |  j ƒ d d ƒ x. |  j D]# } |  j j ƒ  d } |  j | =q& W|  j g  |  j j ƒ  d ƒ d  S(   Ni   s   test requires >=2 itemsi    s   expected empty db after test(   t   assertGreaterEqualR(   R   R   RM   R&   R5   (   R   t   _R=   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_first_while_deleting­   s
    c         C   sm   |  j  t |  j ƒ d d ƒ x. |  j D]# } |  j j ƒ  d } |  j | =q& W|  j g  |  j j ƒ  d ƒ d  S(   Ni   s   test requires >=2 itemsi    s   expected empty db after test(   RU   R(   R   R   RR   R&   R5   (   R   RV   R=   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_last_while_deletingµ   s
    c         C   s-   |  j  |  j j d ƒ d |  j d f ƒ d  S(   NR   (   R&   R   t   set_locationR   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_set_location½   s    c         C   s>   x$ |  j  D] } |  j | |  j ƒ q
 W|  j d |  j ƒ d  S(   Ns   not here(   R   R+   R   t   assertNotIn(   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_containsÀ   s    c         C   sJ   x* |  j  D] } |  j |  j j | ƒ ƒ q
 W|  j |  j j d ƒ ƒ d  S(   Ns   not here(   R   t
   assertTrueR   t   has_keyt   assertFalse(   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_has_keyÅ   s    c         C   s*   |  j  j ƒ  |  j t |  j  ƒ d ƒ d  S(   Ni    (   R   t   clearR&   R(   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt
   test_clearÊ   s    i    c         C   s  t  j j ƒ  | r d GHn  |  j j ƒ  \ } } | rB d G| GHn  d |  j | <| r] d GHn  t r—| rq d GHn  |  j j ƒ  } | j ƒ  \ } } | r  d GHn  d |  j | <| r» d GHn  x/ y | j ƒ  \ } } Wq¾ t k
 rè Pq¾ Xq¾ W| rû d	 GHn  t	 |  j ƒ } | rd
 GHn  xk | r…yG | r2d GHn  | j ƒ  } | rLd GHn  d |  j | <| rgd GHn  Wqt k
 r�d  } qXqW| r—d GHq—n  |  j |  j j ƒ  d |  j ƒ |  j j ƒ  d } |  j | |  j ƒ d |  j | <|  j |  j | d ƒ d  S(   Nt   At   Bs0   deadlock.  do not pass go.  do not collect $200.t   Ct   Dt   Es   please don't deadlockt   Ft   F2t   Gt   Ht   Is   deadlocks-r-ust   Jt   Ki    s   be gone with ye deadlocks(   t   syst   stdoutt   flushR   RM   t   TrueR   R:   R;   R9   R!   R+   R   R]   (   R   t   debugR   R   RP   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test__no_deadlock_firstÎ   s`          	  	     c         C   s¤   t  |  j j ƒ } |  j j ƒ  } t  |  j j ƒ } | j ƒ  \ } } t  |  j j ƒ } ~ t  |  j j ƒ } |  j | | ƒ |  j | | ƒ |  j | | d ƒ d  S(   Ni   (   R(   R   t   _cursor_refsR   R:   R&   (   R   t   nc1RP   t   nc2R   R   t   nc3t   nc4(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_for_cursor_memleak  s    c         C   s~   |  j  j ƒ  \ } } |  j | |  j ƒ |  j | |  j j ƒ  ƒ |  j | |  j  ƒ |  j t |  j ƒ d t |  j  ƒ ƒ d  S(   Ni   (   R   t   popitemR+   R   R-   R[   R&   R(   (   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_popitem  s
    c         C   s…   d } |  j  j | ƒ } |  j | |  j | ƒ |  j | |  j  ƒ |  j | |  j  j ƒ  ƒ |  j t |  j ƒ d t |  j  ƒ ƒ d  S(   NR
   i   (   R   t   popR&   R   R[   R-   R(   (   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_pop  s    c         C   se   |  j  |  j j d ƒ d  ƒ |  j  |  j j d d ƒ d ƒ |  j  |  j j d d ƒ |  j d ƒ d  S(   Nt   NotHeret   DefaultR   (   R&   R   t   getR!   R   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_get#  s    c         C   sI   |  j  |  j j d d ƒ d ƒ |  j  |  j j d d ƒ |  j d ƒ d  S(   Nt   newt   dogR   t   cat(   R&   R   t
   setdefaultR   (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_setdefault(  s    c         C   sv   t  d d d d d d ƒ } |  j j | ƒ |  j j | ƒ x4 |  j j ƒ  D]# \ } } |  j |  j | | ƒ qK Wd  S(   NR   t   lifet   ut   ofRP   t   brian(   R   R   t   updateR   R   R&   (   R   Rƒ   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_update,  s
    c         C   sÔ   |  j  |  j d t j ƒ |  j j ƒ  } | j ƒ  |  j |  j j	 ƒ  d | d ƒ |  j |  j j
 ƒ  d | d ƒ |  j |  j j ƒ  d | d ƒ |  j |  j j ƒ  d | d ƒ |  j t |  j ƒ | ƒ d  S(   Ni    i   iÿÿÿÿiþÿÿÿ(   t   assertIsR   R   t   btopenR   R,   t   sortR&   R   RM   R:   RR   RS   t   list(   R   R,   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   test_keyordering3  s    
!!!!(   t   __name__t
   __module__R   R   R%   R'   R)   R.   R0   R4   R8   R@   RG   RK   RL   RQ   RT   RW   RX   RZ   R\   R`   Rb   Rt   Rz   R|   R~   R‚   R‡   R�   R’   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyR      s:   		
																		4						t	   TestBTreec           B   s   e  Z e j Z e j g Z RS(    (   R“   R”   R    t   TESTFNR   R   R�   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyR•   =  s   	t   TestBTree_InMemoryc           B   s    e  Z d  Z e j g Z d  Z RS(   N(   R“   R”   R!   R   R   R�   R   R0   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyR—   A  s   t   TestBTree_InMemory_Truncatec           B   s&   e  Z d Z d  Z e j g Z d Z RS(   t   nN(	   R“   R”   R!   R   R   R   R�   R   R0   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyR˜   H  s   t   TestHashTablec           B   s#   e  Z e j Z e j g Z d  Z	 RS(   N(
   R“   R”   R    R–   R   R   t   hashopenR   R!   R’   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyRš   P  s   	t   TestHashTable_InMemoryc           B   s&   e  Z d  Z e j g Z d  Z d  Z RS(   N(	   R“   R”   R!   R   R   R›   R   R0   R’   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyRœ   W  s   c         C   s   t  j t t t t t ƒ d  S(   N(   R    t   run_unittestR•   Rš   R—   Rœ   R˜   (   t   verbose(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt	   test_maine  s    t   __main__Rž   (   t   __doc__R"   Ro   t   unittestt   testR    t   import_moduleRr   R   t   TestCaseR   R•   R—   R˜   Rš   Rœ   R!   RŸ   R“   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_bsddb.pyt   <module>   s    ÿ .	