ó
�wÛjc           @   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   sb   e  Z d  „  Z d „  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(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   setUp   s    c         C   s   d  S(   N(    (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   tearDown   s    c         C   s<   t  j d ƒ } |  j t ƒ � | j d  d „  ƒ Wd  QXd  S(   Ns   :memory:c         S   s   |  | k |  | k  S(   N(    (   t   xt   y(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   <lambda>%   t    (   t   sqlitet   connectt   assertRaisest	   TypeErrort   create_collationt   None(   R   t   con(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckCreateCollationNotString"   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(   R   R	   R   t   failR   t   assertEqualt   args(   R   R   t   e(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckCreateCollationNotAscii/   s    c         C   s�   d t  f d „  ƒ  Y} t j d ƒ } d „  } | j | d ƒ | ƒ | j d ƒ j ƒ  } |  j | d d d ƒ |  j | d	 d d
 ƒ d  S(   Nt   BadUpperStrc           B   s   e  Z d  „  Z RS(   c         S   s   d  S(   N(   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   upper9   s    (   t   __name__t
   __module__R   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR   8   s   s   :memory:c         S   s   |  | k |  | k  S(   N(    (   R   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR   <   R   t   mycolls›   
            select x from (
            select 'a' as x
            union
            select 'b' as x
            ) order by x collate mycoll
            i    t   bi   t   a(   t   strR   R	   R   t   executet   fetchallR   (   R   R   R   R   t   result(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckCreateCollationBadUpper7   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   (   R   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR   K   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   cR   R   s#   the expected order was not returneds&   should have raised an OperationalErrors"   no such collation sequence: mycoll(   i   i   i   (   R   t   version_infoR	   R   R!   R"   R   R   t   OperationalErrorR   R   t   lower(   R   R   R   t   sqlR#   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckCollationIsUsedH   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   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR   f   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#   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt!   CheckCollationReturnsLargeIntegere   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   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR      R   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#   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckCollationRegisterTwicex   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   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckDeregisterCollation†   s    (   R   R   R   R   R   R   R   R$   R*   R,   R-   R/   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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(    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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   R3   (    (   R2   sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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 | | ƒ d S(   s=   
        Test that the opcode argument is respected.
        s   :memory:c              s   ˆ  j  d  ƒ d S(   Ni    (   R1   R   (    (   R2   (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR3   ¬   s    i   s1   
            create table foo (a, b)
            i   s1   
            create table bar (a, b)
            N(   R   R	   R4   t   cursorR!   t   lent   assertGreaterEqual(   R   R   R3   t   curst   first_countt   second_count(    (   R2   sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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   (   R1   R   (    (   R2   (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR3   Ã   s    i   s   create table bar (a, b)N(   R   R	   R4   R7   R
   R'   R!   (   R   R   R3   R:   (    (   R2   sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/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    (   R1   (    (   t   action(    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR3   Ó   s    i   s&   select 1 union select 2 union select 3i    s    progress handler was not clearedN(   R   R	   R4   R   R!   R"   R   R8   (   R   R   R3   (    (   R?   sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   CheckClearHandlerÍ   s    (   R   R   R6   R=   R>   R@   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyR0   •   s   			c          C   s7   t  j t d ƒ }  t  j t d ƒ } t  j |  | f ƒ S(   Nt   Check(   t   unittestt	   makeSuiteR    R0   t	   TestSuite(   t   collation_suitet   progress_suite(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   suiteÛ   s    c          C   s    t  j ƒ  }  |  j t ƒ  ƒ d  S(   N(   RB   t   TextTestRunnert   runRG   (   t   runner(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   testà   s    t   __main__(
   t   osRB   t   sqlite3R   t   TestCaseR    R0   RG   RK   R   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/sqlite3/test/hooks.pyt   <module>   s   zF		