Ñò
•à"Ic           @   sŸ   d  Z  d d k Z d d k Z d d k Z d d k l Z l Z l Z l Z l	 Z	 l
 Z
 d e i f d „  ƒ  YZ d „  Z e d j o e i d d	 ƒ n d S(
   sU   
Test cases adapted from the test_bsddb.py module in Python's
regression test suite.
iÿÿÿÿN(   t   dbt   hashopent   btopent   rnopent   verboset   get_new_database_patht   CompatibilityTestCasec           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  ƒ  |  _ d  S(   N(   R   t   filename(   t   self(    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   setUp   s    c         C   s1   y t  i |  i ƒ Wn t  i j
 o n Xd  S(   N(   t   ost   removeR   t   error(   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   tearDown   s    c         C   s   |  i  t d ƒ d  S(   NR   (   t   do_bthash_testR   (   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   test01_btopen   s    c         C   s   |  i  t d ƒ d  S(   NR   (   R   R   (   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   test02_hashopen   s    c   	      C   s¬  d i  ƒ  } t o	 d GHn t |  i d ƒ } x, t t | ƒ ƒ D] } | | | | d <qA W| d | d | d f } t o d | GHn |  i | d d d	 ƒ | i d ƒ } | d j o |  i d t	 | ƒ ƒ n d | d <| i
 ƒ  ~ t |  i d ƒ } d | d <d „  } |  i t | | ƒ d „  } |  i t | | ƒ | d =| i ƒ  } xC | o; t o	 | GHn y | i ƒ  } Wq[t j
 o Pq[Xq[W| i
 ƒ  d  S(   Ns-   The quick brown fox jumped over the lazy dog.s   
Testing: rnopent   ci   i   i   s   %s %s %st   quicks   data mismatch!t   browns$   recno database set_location failed: s   twenty-fivei   t   wt   twentyi   c         S   s   |  d } d  S(   Ni   (    (   t   ft   rec(    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   noRec8   s    c         S   s   |  d } d  S(   Ns   a string(    (   R   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   badKey<   s    (   i   R   (   t   splitR   R   R   t   ranget   lent   assertEqualt   set_locationt   failt   reprt   closet   assertRaisest   KeyErrort	   TypeErrort   firstt   next(	   R   t   dataR   t   xt   getTestt   rvR   R   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   test03_rnopen   sD    	 


		 	c         C   s    t  |  i d ƒ } | i ƒ  d  S(   Nt   n(   R   R   R!   (   R   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   test04_n_flagN   s    c         C   s-  t  o d G| GHn | |  i d ƒ } t  o	 d GHn | o t  o	 d GHqa n t  o	 d GHn d | d <d | d	 <d
 | d <d | d <d | d <d | d <t  o" d | d	 | d | d f GHn t  o	 d GHn | i | i ƒ  d ƒ } | d! j o |  i d t | ƒ ƒ n x] y | i ƒ  } Wn7 t j
 o+ |  i | | i	 ƒ  d ƒ | i
 ƒ  Pn Xt  o	 | GHqq|  i | i d ƒ d ƒ | t j o; | i d ƒ } | d" j o |  i d t | ƒ ƒ qn7 y | i d ƒ } Wn t j
 o n X|  i d ƒ | i ƒ  | i ƒ  y/ | o t  o	 d GHqPn t  o	 d GHn Wn t i j
 o n X|  i d ƒ ~ t  o	 d GHn | |  i d ƒ } d | d <t  o	 d GHn x. | i ƒ  D]  } | | } t  o	 | GHqÃqÃWd „  }	 |  i t |	 | ƒ d  „  }
 |  i t |
 | ƒ | i ƒ  d  S(#   Ns
   
Testing: R   s   creation...s   truth test: trues   truth test: falset    t   0t   Guidot   at   vant   bt   Rossumt   inventedt   dt   PythonR   s   %s %s %ss   key ordering...i    s   incorrect first() result: s   Error, last <> last!s   Error, missing key!t   es   wrong key,value returned: s7   set_location on non-existant key did not raise KeyErrors   Exception expecteds   modification...R   t
   discovereds	   access...c         S   s   |  d } d  S(   Ns   no such key(    (   R   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyR   ¥   s    c         S   s   |  d } d  S(   Ni   (    (   R   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyR   ©   s    (   R/   R.   (   R   s   Python(   R   R   R   R%   R   R    R&   R#   R   t   lastt   previoust   assert_t   has_keyR   t   syncR!   R    t   DBErrort   keysR"   R$   (   R   t   factoryt   whatR   t   startR   R8   t   keyt   wordR   R   (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyR   S   sŒ    	  	





"	


  	
	 
		(	   t   __name__t
   __module__R	   R   R   R   R+   R-   R   (    (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyR      s   					0	c           C   s   t  i t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt
   test_suite³   s    t   __main__t   defaultTestRJ   (   t   __doc__R
   t   stringRH   t   test_allR    R   R   R   R   R   t   TestCaseR   RJ   RF   t   main(    (    (    s3   /mit/python/lib/python2.6/bsddb/test/test_compat.pyt   <module>   s   .¦	