ó
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	 y d d l
 Z
 Wn e k
 ru n Xe
 j d d d d e ƒd e j f d	 „  ƒ  YZ d
 „  Z e d k rÐ e j d d ƒ n  d S(   sf   TestCases for checking that it does not segfault when a DBEnv object
is closed before its DB objects.
iÿÿÿÿN(   t   dbt   test_supportt   verboset   get_new_environment_patht   get_new_database_patht   ignoret   messages   DB could not be closed int   categoryt   DBEnvClosedEarlyCrashc           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   s   t  ƒ  |  _ d |  _ d  S(   Nt   test(   R   t   homeDirt   filename(   t   self(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   setUp   s    c         C   s   t  j |  j ƒ d  S(   N(   R   t   rmtreeR
   (   R   (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   tearDown   s    c         C   s   t  j ƒ  } | j |  j t  j t  j Bt  j Bt  j Bd ƒ t  j | ƒ } t  j | ƒ } | j |  j	 t  j
 t  j t  j Bd ƒ |  j t  j | j |  j	 d t  j
 t  j d ƒ | j d d ƒ |  j | j d ƒ d d ƒ | j ƒ  |  j t  j | j d ƒ d  S(   Ni¶  t   2R	   s   this is a tests   put!=get(   R    t   DBEnvt   openR
   t   DB_INIT_CDBt	   DB_CREATEt	   DB_THREADt   DB_INIT_MPOOLt   DBR   t   DB_BTREEt   assertRaisest   DBNoSuchFileErrort   putt   assertEqualt   gett   closet   DBError(   R   t   dbenvt   dt   d2(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   test01_close_dbenv_before_db    s    &
c         C   st  t  j ƒ  } | j |  j t  j t  j Bt  j Bt  j Bd ƒ t  j | ƒ } | j |  j	 t  j
 t  j t  j Bd ƒ | j d d ƒ | j d d ƒ | j d d ƒ |  j | j d ƒ d d ƒ | j ƒ  } | j ƒ  | j ƒ  | j ƒ  |  j t  j | j ƒ t  j | ƒ } | j |  j	 t  j
 t  j t  j Bd ƒ | j ƒ  } | j ƒ  | j ƒ  | j ƒ  |  j t  j | j ƒ d  S(	   Ni¶  R	   s   this is a testt   test2s   another testt   test3s   another ones   put!=get(   R    R   R   R
   R   R   R   R   R   R   R   R   R   R   t   cursort   firstt   nextR   R   R   (   R   R    R!   t   c(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt"   test02_close_dbenv_before_dbcursor2   s,    &


&


c         C   sæ   d d  l  } | j j |  j |  j ƒ } t j ƒ  } | j | t j t j	 t j
 Bd ƒ | j d d ƒ | j d d ƒ | j d d ƒ |  j | j d ƒ d d	 ƒ | j ƒ  } | j ƒ  | j ƒ  | j ƒ  |  j t j | j ƒ d  S(
   Niÿÿÿÿi¶  R	   s   this is a testR$   s   another testR%   s   another ones   put!=get(   t   os.patht   patht   joinR
   R   R    R   R   R   R   R   R   R   R   R&   R'   R(   R   R   R   (   R   t   osR,   R!   R)   (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt+   test03_close_db_before_dbcursor_without_envO   s    #


c         C   s  t  j ƒ  } | j |  j t  j t  j Bt  j Bt  j Bd ƒ g  t d ƒ D] } t  j	 | ƒ ^ qG } g  } x4 | D], } | j |  j
 t  j t  j t  j Bd ƒ qo W| d j d d ƒ | d j d d ƒ | d j d d	 ƒ |  j | d
 j d ƒ d d ƒ x: | D]2 } | j g  t d ƒ D] } | j ƒ  ^ qƒ qWx% | d  d  d … D] } | j ƒ  qLWx% | d  d  d … D] } | j ƒ  qtW|  j t  j | d j d ƒ |  j t  j | d j ƒ | d j ƒ  | d j ƒ  | j ƒ  |  j t  j | d j ƒ d  S(   Ni¶  i   i
   R	   s   this is a testR$   s   another testR%   s   another onei   s   put!=geti    i   i	   ie   iP   (   R    R   R   R
   R   R   R   R   t   xrangeR   R   R   R   R   R   t   extendR&   R   R   R   R'   R(   (   R   R    t   it   dbst   cursorst   j(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   test04_close_massive`   s0    (* 0
c         C   s½   t  j ƒ  } | j |  j t  j t  j Bt  j Bt  j Bd ƒ t  j | ƒ } | j |  j	 t  j
 t  j t  j Bd ƒ | j ƒ  ~ y d d  l } Wn t k
 r¥ d  } n X| r¹ | j ƒ  n  d  S(   Ni¶  iÿÿÿÿ(   R    R   R   R
   R   R   R   R   R   R   R   R   t   gct   ImportErrort   Nonet   collect(   R   R    R!   R7   (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt$   test05_close_dbenv_delete_db_success„   s    &

c         C   so  t  j ƒ  } | j |  j t  j t  j Bt  j Bt  j Bƒ t  j | ƒ } | j	 ƒ  } | j |  j
 d t  j d t  j d | ƒ| j d d d | ƒ| j ƒ  | j	 ƒ  } | j | ƒ } | j ƒ  } |  j d
 | j ƒ  ƒ d d  l } t j d k  r| j d	 ƒ | j ƒ  | j ƒ  n? | j ƒ  } | j ƒ  z | j d	 ƒ | j ƒ  Wd  | j ƒ  X|  j t  j | j ƒ d  S(   Nt   dbtypet   flagst   txnt   XXXt   yyyiÿÿÿÿi   i   R   (   R?   R@   (   i   i   (   R    R   R   R
   t   DB_INIT_TXNR   t   DB_INIT_LOGR   R   t	   txn_beginR   t   DB_HASHR   t   commitR&   t   dupR   R'   t   warningst   syst   version_infot   simplefiltert   resetwarningst   catch_warningst	   __enter__t   __exit__R   t   DBCursorClosedError(   R   R    R!   R>   t   c1t   c2RG   t   w(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt"   test06_close_txn_before_dup_cursor˜   s2    !


c         C   s}   d d  l  } | j j |  j |  j ƒ } t j ƒ  } | j | t j t j	 t j
 Bd ƒ t j | ƒ } | j ƒ  | j ƒ  d  S(   Niÿÿÿÿi¶  (   R+   R,   R-   R
   R   R    R   R   R   R   R   t
   DBSequenceR   (   R   R.   R,   R!   R3   (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   test07_close_db_before_sequenceÅ   s    #
(   t   __name__t
   __module__R   R   R#   R*   R/   R6   R;   RS   RU   (    (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyR      s   						$		-c          C   s&   t  j ƒ  }  |  j t  j t ƒ ƒ |  S(   N(   t   unittestt	   TestSuitet   addTestt	   makeSuiteR   (   t   suite(    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt
   test_suiteÐ   s    t   __main__t   defaultTestR]   (   t   __doc__R.   RH   RX   t   test_allR    R   R   R   R   RG   R8   t   filterwarningst   RuntimeWarningt   TestCaseR   R]   RV   t   main(    (    (    sc   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_early_close.pyt   <module>   s   (¸	