³ò
œ›\Kc           @   sk   d  d k  Z  d  d k Z d  d k Z d e i f d „  ƒ  YZ d „  Z d „  Z e d j o e ƒ  n d S(   iÿÿÿÿNt   CollationTestsc           B   sG   e  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(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   setUp   s    c         C   s   d  S(   N(    (   R   (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   tearDown   s    c         C   sc   t  i d ƒ } y! | i d d ƒ |  i d ƒ Wn, t j
 o  } |  i | i 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   failUnlessEqualt   args(   R   t   cont   e(    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   CheckCreateCollationNotCallable"   s    c         C   sO   t  i d ƒ } y! | i d t ƒ |  i d ƒ Wn t  i j
 o	 } n Xd  S(   Ns   :memory:s   colläs%   should have raised a ProgrammingError(   R   R   R   t   cmpR   t   ProgrammingError(   R   R   R   (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   CheckCreateCollationNotAscii*   s    c         C   s  t  i d j  o d  Sn d „  } t  i d ƒ } | i d | ƒ d } | i | ƒ i ƒ  } | d d d	 j p* | d d d
 j p | d d d j o |  i d ƒ n | i d d  ƒ y& | i | ƒ i ƒ  } |  i d ƒ Wn5 t  i j
 o& } |  i	 | i
 d i ƒ  d ƒ n Xd  S(   Ni   i   i   c         S   s   t  |  | ƒ S(   N(   R   (   t   xt   y(    (    s(   /usr/lib/python2.5/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   (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   CheckCollationIsUsed2   s    		?c         C   s†   t  i d ƒ } | i d t ƒ | i d d „  ƒ | i d ƒ i ƒ  } | d d d j p | d d d j o |  i 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(    (   R   (   R   R   (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   <lambda>V   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   (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   CheckCollationRegisterTwiceO   s    *c         C   s”   t  i d ƒ } | i d t ƒ | i d d ƒ y | i d ƒ |  i d ƒ Wn@ t  i j
 o1 } | i d i	 d ƒ p |  i 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(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   CheckDeregisterCollation]   s    (	   t   __name__t
   __module__R   R   R   R   R    R"   R$   (    (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyR       s   						c          C   s"   t  i t d ƒ }  t  i |  f ƒ S(   Nt   Check(   t   unittestt	   makeSuiteR    t	   TestSuite(   t   collation_suite(    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   suitel   s    c          C   s    t  i ƒ  }  |  i t ƒ  ƒ d  S(   N(   R(   t   TextTestRunnert   runR,   (   t   runner(    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pyt   testp   s    t   __main__(	   t   osR(   t   sqlite3R   t   TestCaseR    R,   R0   R%   (    (    (    s(   /usr/lib/python2.5/sqlite3/test/hooks.pys   <module>   s   Q		