Ñò
•à"Ic           @   s¯   d  Z  d d k Z d d k Z d d k l Z d d k Z d d k l Z l Z l Z l	 Z	 l
 Z
 d Z d e i f d „  ƒ  YZ d „  Z e d	 j o e i 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_patht4   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZt   SimpleRecnoTestCasec           B   se   e  Z d  d k Z e i d  d j  o d d „ Z n d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 RS(   iÿÿÿÿNi   i   i   i    c         C   s   |  i  | d | ƒd  S(   Nt   msg(   t   failIf(   t   selft   exprR   (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   assertFalse   s    c         C   s   t  ƒ  |  _ d  |  _ d  S(   N(   R   t   filenamet   Nonet   homeDir(   R
   (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   setUp   s    c         C   s2   t  i |  i ƒ |  i o t  i |  i ƒ n d  S(   N(   R   t   unlinkR   R   t   rmtree(   R
   (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   tearDown   s    
c         C   s  t  i ƒ  } | i d ƒ } | i | ƒ | i |  i t  i t  i ƒ x_ t D]W } | i | d ƒ } |  i	 t
 | ƒ t
 d ƒ ƒ |  i | d j ƒ t o | GqK qK Wt o Hn | i ƒ  } t o t | ƒ n xp t d t | ƒ d ƒ D]U } | | } t o	 | GHn |  i	 t
 | ƒ t
 d ƒ ƒ |  i	 | | i | ƒ ƒ qí Wy | d } Wn} t  i j
 on } d d  k } | i d d j  o |  i	 | d t  i ƒ n |  i	 | i d t  i ƒ t o	 | GHqán X|  i d ƒ y | i d ƒ Wn t  i j
 o	 } n X|  i d	 ƒ y | d
 } Wn t j
 o n X|  i d ƒ y | i d
 ƒ } Wn0 t  i j
 o! } | o |  i d ƒ q¡n X|  i	 | d  ƒ | i ƒ  }	 t o	 |	 GHn |  i	 t
 |	 ƒ t
 g  ƒ ƒ |  i	 t
 |	 d ƒ t
 d ƒ ƒ |  i	 t |	 ƒ t | ƒ ƒ | i ƒ  }
 t o t |
 ƒ n |  i	 t
 |
 ƒ t
 g  ƒ ƒ |  i	 t
 |
 d ƒ t
 d ƒ ƒ |  i	 t |
 d ƒ d ƒ |  i	 t
 |
 d d ƒ t
 d ƒ ƒ |  i	 t
 |
 d d ƒ t
 d ƒ ƒ |  i	 t |
 ƒ t | ƒ ƒ |  i | i d ƒ ƒ | d =|  i | i d ƒ ƒ | i  d ƒ |  i | i d ƒ ƒ | i! d d d ƒ } |  i	 | d d d | ƒ t o	 | GHn | i" ƒ  } t o	 | GHn | i# ƒ  } | i$ ƒ  } x( | o  t o	 | GHn | i% ƒ  } q¾W| i& d ƒ | i' ƒ  } t o	 | GHn | i( d d t  i) ƒ | i& d ƒ | i' ƒ  } |  i	 | d ƒ t o	 | GHn | i* d ƒ } t o	 | GHn | i* d ƒ } |  i	 | d  ƒ t o	 | GHn | i+ ƒ  | i+ ƒ  t  i ƒ  } | i |  i ƒ | i# ƒ  } d | d
 <|  i	 | d
 d ƒ y | d } Wn t j
 o n X|  i d ƒ y | i d ƒ WnW t  i, j
 oH } | o |  i d ƒ qº|  i	 | d t  i- ƒ t o	 | GHqºn X| p |  i d ƒ n | i& d ƒ } x( | o  t o	 | GHn | i% ƒ  } qÌW| i+ ƒ  | i+ ƒ  d  S(   Ni   i<   i    i   t    iÿÿÿÿi   s   expected exceptions(   has_key did not raise a proper exceptionid   s   unexpected exceptioni{   i   i   i   t   zs   was %ri2   s   a replacement recordi   i?B s   way out thereic   s$   unexpected DBKeyEmptyError exceptioni(   (    (   i2   s   a replacement record(.   R   t   DBt   set_get_returns_nonet   openR   t   DB_RECNOt	   DB_CREATEt   letterst   appendt   assertEqualt   typet   assert_R   t   statR    t   ranget   lent   gett   DBInvalidArgErrort   syst   version_infot   EINVALt   argst   failt   has_keyt   DBErrort   KeyErrort   DBNotFoundErrorR   t   keyst   itemsR   t   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   valR%   R.   R/   R2   t   ct   rec(    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   test01_basic   s      
	 	  $$		 					


  	
c         C   s  t  ƒ  } | |  _ t i i | d ƒ } t i i | ƒ p t i | ƒ n t | d ƒ } | i ƒ  t	 i
 ƒ  } | i d ƒ | i d ƒ | i | ƒ | i |  i t	 i t	 i ƒ d i ƒ  } x | D] } | i | ƒ qÆ W| i ƒ  | i ƒ  t | d ƒ i ƒ  } | i ƒ  } t o | GH| GH| i d ƒ GHn |  i | i d ƒ | ƒ t	 i
 ƒ  } | i | ƒ | i |  i t	 i ƒ d | d <d	 | d
 <| i ƒ  | i ƒ  t | d ƒ i ƒ  } | i ƒ  } t o | GH| i d ƒ GHn |  i | i d ƒ d i ƒ  ƒ 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   R;   R   R   t   set_re_delimt   set_re_sourceR   R   R   t   splitR   t   synct   readt   stripR   R   (   R
   R   t   sourcet   fR>   RB   t   datumt   text(    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   test02_WithSourceÇ   sN    		
 





c         C   s  t  i ƒ  } | i d ƒ | i d ƒ | i d ƒ | i |  i t  i t  i ƒ x t D] } | i	 | d ƒ qV W| i	 d d ƒ y | i	 d d ƒ Wn} t  i
 j
 on } d d  k } | i d	 d
 j  o |  i | d	 t  i ƒ n |  i | i d	 t  i ƒ t o	 | GHq$n X|  i d ƒ | i ƒ  } | i ƒ  } x( | o  t o	 | GHn | i ƒ  } q?W| i ƒ  | i ƒ  d  S(   Ni(   t   -i-   i#   t   .t   badi   iÿÿÿÿi    i   s   expected exception(   R   R   t
   set_re_lent
   set_re_padR   R   R   R   R   R   R$   R%   R&   R   R'   R(   R   R)   R3   R4   R5   R;   (   R
   R>   R@   RC   R%   RD   RE   (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   test03_FixedLength  s8       	
(   i   i   i    (   t   __name__t
   __module__R%   R&   R   R   R   R   RF   RY   R_   (    (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyR      s   			¨	:c           C   s   t  i t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt
   test_suite'  s    t   __main__t   defaultTestRd   (   t   __doc__RJ   t   errnoR    Rb   t   test_allR   R   R   R   R   R   t   TestCaseR   Rd   R`   t   main(    (    (    s2   /mit/python/lib/python2.6/bsddb/test/test_recno.pyt   <module>   s   (ÿ 	