ó
X\¬Qc           @   s   d  Z  d d l Z d d l Z d d l Z d d l m Z 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(
   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(    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   setUp   s    c         C   s/   y t  j |  j ƒ Wn t  j k
 r* n Xd  S(   N(   t   ost   removeR   t   error(   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   tearDown   s    c         C   s   |  j  t d ƒ d  S(   NR   (   t   do_bthash_testR   (   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   test01_btopen   s    c         C   s   |  j  t d ƒ d  S(   NR   (   R   R   (   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   test02_hashopen   s    c   	      C   s   d j  ƒ  } t r d GHn  t |  j d ƒ } x, t t | ƒ ƒ D] } | | | | d <q? W| d | d | d f } t rˆ d | GHn  |  j | d d d	 ƒ | j d ƒ } | d k rÔ |  j d t	 | ƒ ƒ n  d | d <| j
 ƒ  ~ t |  j d ƒ } d | d <d „  } |  j t | | ƒ d „  } |  j t | | ƒ | d =| j ƒ  } x= | r‘t ri| GHn  y | j ƒ  } WqUt k
 rPqUXqUW| j
 ƒ  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(    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   noRec8   s    c         S   s   |  d } d  S(   Ns   a string(    (   R   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/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   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   test03_rnopen   s@    


				c         C   s    t  |  j d ƒ } | j ƒ  d  S(   Nt   n(   R   R   R!   (   R   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   test04_n_flagN   s    c         C   s  t  r d G| GHn  | |  j d ƒ } t  r2 d GHn  | rI t  rW d GHqW n t  rW d GHn  d | d <d | d	 <d
 | d <d | d <d | d <d | d <t  rº d | d	 | d | d f GHn  t  rÈ d GHn  | j | j ƒ  d ƒ } | d! k r|  j d t | ƒ ƒ n  xY y | j ƒ  } Wn5 t k
 rQ|  j | | j	 ƒ  d ƒ | j
 ƒ  Pn Xt  r
| GHq
q
|  j | j d ƒ d ƒ | t k rÀ| j d ƒ } | d" k rô|  j d t | ƒ ƒ qôn4 y | j d ƒ } Wn t k
 ræn X|  j d ƒ | j ƒ  | j ƒ  y) | r"t  r0d GHq0n t  r0d GHn  Wn t j k
 rGn X|  j d ƒ ~ t  rfd GHn  | |  j d ƒ } d | d <t  rd GHn  x, | j ƒ  D] } | | } t  r| GHqqWd „  }	 |  j t |	 | ƒ d  „  }
 |  j t |
 | ƒ | j ƒ  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-existent key did not raise KeyErrors   Exception expecteds   modification...R   t
   discovereds	   access...c         S   s   |  d } d  S(   Ns   no such key(    (   R   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyR   ¥   s    c         S   s   |  d } d  S(   Ni   (    (   R   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyR   ©   s    (   R/   R.   (   R   s   Python(   R   R   R   R%   R   R    R&   R#   R   t   lastt   previoust
   assertTruet   has_keyR   t   syncR!   R    t   DBErrort   keysR"   R$   (   R   t   factoryt   whatR   t   startR   R8   t   keyt   wordR   R   (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyR   S   sŠ      





!


  

		(	   t   __name__t
   __module__R	   R   R   R   R+   R-   R   (    (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyR      s   					0	c           C   s   t  j t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/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(    (    (    s^   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_compat.pyt   <module>   s   .¦	