ó
�wÛjc           @   s¿   d  Z  d d l Z d d l Z d d l Z d d l m Z d d l Z d d l Z d d l m Z m	 Z	 m
 Z
 m Z m Z d e j f d „  ƒ  YZ d „  Z e d k r» e j d	 d
 ƒ n  d S(   s%   TestCases for exercising a Recno DB.
iÿÿÿÿN(   t   pprint(   t   dbt   test_supportt   verboset   get_new_environment_patht   get_new_database_patht   SimpleRecnoTestCasec           B   s†   e  Z e j d k  s3 e j d k rN e j d k  rN d d „ Z d d „ Z n  d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z RS(   i   i   i   i    c         C   s   |  j  t | ƒ | d | ƒS(   Nt   msg(   t   assertEqualt   type(   t   selft   objt   datatypeR   (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   assertIsInstance   s    c         C   s   |  j  | | d | ƒS(   NR   (   t   assertGreaterEqual(   R
   t   at   bR   (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyR      s    c         C   s   t  ƒ  |  _ d  |  _ d  S(   N(   R   t   filenamet   Nonet   homeDir(   R
   (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   setUp   s    c         C   s0   t  j |  j ƒ |  j r, t  j |  j ƒ n  d  S(   N(   R   t   unlinkR   R   t   rmtree(   R
   (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   tearDown   s    	c         C   s�  t  j ƒ  } | j d ƒ } | j | ƒ | j |  j t  j t  j ƒ xQ t j D]F } | j	 | d ƒ } |  j
 | t ƒ |  j | d ƒ t rN | GqN qN Wt r¢ Hn  | j ƒ  } t rÁ t | ƒ n  xb t d t | ƒ d ƒ D]G } | | } t rù | GHn  |  j
 | t ƒ |  j | | j | ƒ ƒ qÛ Wy | d } Wng t  j k
 r�} t j d k  rr|  j | d t  j ƒ n |  j | j d t  j ƒ t r«| GHq«n X|  j d ƒ y | j d ƒ Wn t  j k
 rÔ} n X|  j d ƒ y | d } Wn t k
 rn X|  j d ƒ y | j d ƒ } Wn, t  j k
 rR} | rc|  j d	 ƒ qcn X|  j | d  ƒ | j  ƒ  } t r}| GHn  |  j
 | t! ƒ |  j
 | d t ƒ |  j t | ƒ t | ƒ ƒ | j" ƒ  }	 t rÜt |	 ƒ n  |  j
 |	 t! ƒ |  j
 |	 d t# ƒ |  j t |	 d ƒ d ƒ |  j
 |	 d d t ƒ |  j
 |	 d d t ƒ |  j t |	 ƒ t | ƒ ƒ |  j$ | j d
 ƒ ƒ | d
 =|  j% | j d
 ƒ ƒ | j& d ƒ |  j% | j d ƒ ƒ | j' d d d ƒ } |  j | d d d | ƒ t rû| GHn  | j( ƒ  }
 t r|
 GHn  | j) ƒ  } | j* ƒ  } x$ | rSt rD| GHn  | j+ ƒ  } q0W| j, d ƒ | j- ƒ  } t r{| GHn  | j. d d t  j/ ƒ | j, d ƒ | j- ƒ  } |  j | d ƒ t rÈ| GHn  | j0 d ƒ } t rå| GHn  | j0 d ƒ } |  j | d  ƒ t r| GHn  | j1 ƒ  | j1 ƒ  t  j ƒ  } | j |  j ƒ | j) ƒ  } d | d <|  j | d d ƒ y | d } Wn t k
 r�n X|  j d ƒ y | j d ƒ Wn} t  j2 k
 r+} | r×|  j d ƒ qBt j d k  r |  j | d t  j3 ƒ n |  j | j d t  j3 ƒ t rB| GHqBn X| sB|  j d ƒ n  | j, d ƒ } x$ | rwt rh| GHn  | j+ ƒ  } qTW| j1 ƒ  | j1 ƒ  d  S(   Ni   i<   i   i    i   s   expected exceptions(   has_key did not raise a proper exceptionid   s   unexpected exceptioni   i   i   t   zs   was %ri2   iÿÿÿÿs   a replacement recordi   i?B s   way out thereic   s$   unexpected DBKeyEmptyError exceptioni(   (   i   i   (   i2   s   a replacement record(   i   i   (4   R   t   DBt   set_get_returns_nonet   openR   t   DB_RECNOt	   DB_CREATEt   stringt   ascii_letterst   appendR   t   intR   R   t   statR    t   ranget   lent   strR   t   gett   DBInvalidArgErrort   syst   version_infot   EINVALt   argst   failt   has_keyt   DBErrort   KeyErrort   DBNotFoundErrorR   t   keyst   listt   itemst   tuplet
   assertTruet   assertFalset   deletet   get_botht   fdt   cursort   firstt   nextt   sett   currentt   putt
   DB_CURRENTt	   set_ranget   closet   DBKeyEmptyErrort   DB_KEYEMPTY(   R
   t   dt   get_returns_nonet   xt   recnoR"   t   datat   valR1   R3   R9   t   ct   rec(    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   test01_basic!   sþ      
 	


 	
c         C   s!  t  ƒ  } | |  _ t j j | d ƒ } t j j | ƒ sI t j | ƒ n  t | d ƒ } | j ƒ  t	 j
 ƒ  } | j d ƒ | j d ƒ | j | ƒ | j |  j t	 j t	 j ƒ d j ƒ  } x | D] } | j | ƒ qÄ W| j ƒ  | j ƒ  t | d ƒ } | j ƒ  } | j ƒ  | j ƒ  } t rA| GH| GH| j d ƒ GHn  |  j | j d ƒ | ƒ t	 j
 ƒ  } | j | ƒ | j |  j t	 j ƒ d | d <d	 | d
 <| j ƒ  | j ƒ  t | d ƒ } | j ƒ  } | j ƒ  | j ƒ  } t rþ| GH| j d ƒ GHn  |  j | j d ƒ d j ƒ  ƒ d S(   s  
        A Recno file that is given a "backing source file" is essentially a
        simple ASCII file.  Normally each record is delimited by 
 and so is
        just a line in the file, but you can set a different record delimiter
        if needed.
        s   test_recno.txtt   wi
   s   
s,   The quick brown fox jumped over the lazy dogt   rs   reddish-browni   t   comatosei   s8   The quick reddish-brown fox jumped over the comatose dogN(   R   R   t   ost   patht   joint   isdirt   mkdirR   RB   R   R   t   set_re_delimt   set_re_sourceR   R   R   t   splitR    t   synct   readt   stripR   R   (   R
   R   t   sourcet   fRE   RI   t   datumt   text(    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   test02_WithSourceË   sT    		








c         C   sh  t  j ƒ  } | j d ƒ | j d ƒ | j d ƒ | j |  j t  j t  j ƒ x" t j	 D] } | j
 | d ƒ qY W| j
 d d ƒ y | j
 d d ƒ Wng t  j k
 r} t j d k  rØ |  j | d
 t  j ƒ n |  j | j d
 t  j ƒ t r| GHqn X|  j d ƒ | j ƒ  } | j ƒ  } x$ | rOt r@| GHn  | j ƒ  } q,W| j ƒ  | j ƒ  d  S(   Ni(   t   -i-   i#   t   .t   badi   i   i   i    s   expected exception(   i   i   (   R   R   t
   set_re_lent
   set_re_padR   R   R   R   R   R   R    R'   R(   R)   R   R*   R+   R   R,   R:   R;   R<   RB   (   R
   RE   RG   RJ   RK   RL   (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   test03_FixedLength	  s2     	
c         C   sˆ   t  j ƒ  } | j |  j d t  j d t  j ƒ| j d ƒ } |  j d | j d | ƒ ƒ | j d ƒ } |  j d | j d | ƒ ƒ d  S(   Nt   dbtypet   flagst    i   t   keyt    i    (	   R   R   R   R   R   R   R    R   t   get_size(   R
   RE   t   row_id(    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   test04_get_size_empty*  s    "(   i   i   (   i   i    (   i   i   N(   t   __name__t
   __module__R(   R)   R   R   R   R   R   RM   R`   Rf   Rn   (    (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyR      s   			ª	>	!c           C   s   t  j t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt
   test_suite:  s    t   __main__t   defaultTestRs   (   t   __doc__RQ   R(   t   errnoR    R   Rq   t   test_allR   R   R   R   R   t   TestCaseR   Rs   Ro   t   main(    (    (    s‹   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/bsddb/test/test_recno.pyt   <module>   s   (ÿ ,	