ó
X\¬Qc           @   s‚   d  d l  Z  d  d l Z d  d l Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d „  Z d „  Z e	 d k r~ e ƒ  n  d S(	   iÿÿÿÿNt   CollationTestsc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   s   d  S(   N(    (   t   self(    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   setUp   s    c         C   s   d  S(   N(    (   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   tearDown   s    c         C   sa   t  j d ƒ } y! | j d d ƒ |  j d ƒ Wn* t k
 r\ } |  j | j d d ƒ n Xd  S(   Ns   :memory:t   Xi*   s   should have raised a TypeErrori    s   parameter must be callable(   t   sqlitet   connectt   create_collationt   failt	   TypeErrort   assertEqualt   args(   R   t   cont   e(    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckCreateCollationNotCallable"   s    c         C   sM   t  j d ƒ } y! | j d t ƒ |  j d ƒ Wn t  j k
 rH } n Xd  S(   Ns   :memory:s   colläs%   should have raised a ProgrammingError(   R   R   R   t   cmpR   t   ProgrammingError(   R   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckCreateCollationNotAscii*   s    c         C   s  t  j d k  r d  Sd „  } t  j d ƒ } | j d | ƒ d } | j | ƒ j ƒ  } | d d d	 k s’ | d d d
 k s’ | d d d k r¢ |  j d ƒ n  | j d d  ƒ y& | j | ƒ j ƒ  } |  j d ƒ Wn3 t  j k
 r} |  j	 | j
 d j ƒ  d ƒ n Xd  S(   Ni   i   i   c         S   s   t  |  | ƒ S(   N(   R   (   t   xt   y(    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   mycoll5   s    s   :memory:R   sÉ   
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            i    t   ct   bt   as#   the expected order was not returneds&   should have raised an OperationalErrors"   no such collation sequence: mycoll(   i   i   i   (   R   t   version_infoR   R   t   executet   fetchallR   t   Nonet   OperationalErrorR
   R   t   lower(   R   R   R   t   sqlt   resultR   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckCollationIsUsed2   s    		<c         C   sf   d „  } t  j d ƒ } | j d | ƒ d } | j | ƒ j ƒ  } |  j | d
 d d g d d	 ƒd  S(   Nc         S   s   |  | k |  | k  d S(   Ni   i    I       (    (   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR   P   s    s   :memory:R   sÉ   
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            R   R   R   t   msgs#   the expected order was not returned(   R   (   R   (   R   (   R   R   R   R   R   R
   (   R   R   R   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt!   CheckCollationReturnsLargeIntegerO   s    		c         C   sƒ   t  j d ƒ } | j d t ƒ | j d d „  ƒ | j d ƒ j ƒ  } | d d d k so | d d d k r |  j d	 ƒ n  d
 S(   s„   
        Register two different collation functions under the same name.
        Verify that the last one is actually used.
        s   :memory:R   c         S   s   t  |  | ƒ S(   N(   R   (   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   <lambda>i   s    si   
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            i    R   i   R   s    wrong collation function is usedN(   R   R   R   R   R   R   R   (   R   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckCollationRegisterTwiceb   s    (c         C   s   t  j d ƒ } | j d t ƒ | j d d ƒ y | j d ƒ |  j d ƒ Wn< t  j k
 r‹ } | j d j	 d ƒ sŒ |  j d ƒ qŒ n Xd S(	   su   
        Register a collation, then deregister it. Make sure an error is raised if we try
        to use it.
        s   :memory:R   s?   select 'a' as x union select 'b' as x order by x collate mycolls&   should have raised an OperationalErrori    s   no such collation sequences   wrong OperationalError raisedN(
   R   R   R   R   R   R   R   R   R   t
   startswith(   R   R   R   (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckDeregisterCollationp   s    (
   t   __name__t
   __module__R   R   R   R   R    R"   R$   R&   (    (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR       s   							t   ProgressTestsc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c            sR   t  j d ƒ } g  ‰  ‡  f d †  } | j | d ƒ | j d ƒ |  j ˆ  ƒ d S(   sK   
        Test that the progress handler is invoked once it is set.
        s   :memory:c              s   ˆ  j  d  ƒ d S(   Ni    (   t   appendR   (    (   t   progress_calls(    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   progress†   s    i   s0   
            create table foo(a, b)
            N(   R   R   t   set_progress_handlerR   t
   assertTrue(   R   R   R,   (    (   R+   sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckProgressHandlerUsed€   s    c            sŸ   t  j d ƒ } g  ‰  ‡  f d †  } | j | d ƒ | j ƒ  } | j d ƒ t ˆ  ƒ } g  ‰  | j | d ƒ | j d ƒ t ˆ  ƒ } |  j | | k ƒ d S(   s=   
        Test that the opcode argument is respected.
        s   :memory:c              s   ˆ  j  d  ƒ d S(   Ni    (   R*   R   (    (   R+   (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR,   –   s    i   s1   
            create table foo (a, b)
            i   s1   
            create table bar (a, b)
            N(   R   R   R-   t   cursorR   t   lenR.   (   R   R   R,   t   curst   first_countt   second_count(    (   R+   sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckOpcodeCount   s    c            s]   t  j d ƒ } g  ‰  ‡  f d †  } | j | d ƒ | j ƒ  } |  j t  j | j d ƒ d S(   sW   
        Test that returning a non-zero value stops the operation in progress.
        s   :memory:c              s   ˆ  j  d  ƒ d S(   Ni   (   R*   R   (    (   R+   (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR,   ­   s    i   s   create table bar (a, b)N(   R   R   R-   R0   t   assertRaisesR   R   (   R   R   R,   R2   (    (   R+   sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckCancelOperation§   s    c            st   t  j d ƒ } g  ‰  ‡  f d †  } | j | d ƒ | j d d ƒ | j d ƒ j ƒ  |  j t ˆ  ƒ d d ƒ d S(   sc   
        Test that setting the progress handler to None clears the previously set handler.
        s   :memory:c              s   ˆ  j  d ƒ d S(   Ni   i    (   R*   (    (   t   action(    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR,   ½   s    i   s&   select 1 union select 2 union select 3i    s    progress handler was not clearedN(   R   R   R-   R   R   R   R
   R1   (   R   R   R,   (    (   R8   sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   CheckClearHandler·   s    (   R'   R(   R/   R5   R7   R9   (    (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyR)      s   			c          C   s7   t  j t d ƒ }  t  j t d ƒ } t  j |  | f ƒ S(   Nt   Check(   t   unittestt	   makeSuiteR    R)   t	   TestSuite(   t   collation_suitet   progress_suite(    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   suiteÅ   s    c          C   s    t  j ƒ  }  |  j t ƒ  ƒ d  S(   N(   R;   t   TextTestRunnert   runR@   (   t   runner(    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   testÊ   s    t   __main__(
   t   osR;   t   sqlite3R   t   TestCaseR    R)   R@   RD   R'   (    (    (    sZ   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/sqlite3/test/hooks.pyt   <module>   s   dF		