+
    Bi4                        ^ RI t ^ RIt^ RIt^ RIHtHt ^RIHtH	t	H
t
 ^RIHt  ! R R]]P                  4      t ! R R]]P                  4      t ! R	 R
]]P                  4      t]R8X  d   ]P"                  ! 4        R# R# )    N)TESTFNunlink)memory_databasecx_limitwith_tracebacks)MemoryDatabaseMixinc                   P   a  ] tR t^!t o R tR tR tR tR tR t	R t
R tR	tV tR
# )CollationTestsc                    V P                  \        4      ;_uu_ 4        V P                  P                  R R 4       R R R 4       R #   + '       g   i     R # ; i)Nc                     W8  W8  ,
          # N xys   &&3/usr/lib/python3.14/test/test_sqlite3/test_hooks.py<lambda>ACollationTests.test_create_collation_not_string.<locals>.<lambda>%       !%AE9J    )assertRaises	TypeErrorconcreate_collationselfs   &r    test_create_collation_not_string/CollationTests.test_create_collation_not_string#   s7    y))HH%%d,JK *)))s   AA	c                    V P                  \        4      ;_uu_ 4       pV P                  P                  R ^*4       RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)XNzparameter must be callable)r   r   r   r   assertEqualstr	exception)r   cms   & r   "test_create_collation_not_callable1CollationTests.test_create_collation_not_callable'   sQ    y))RHH%%c2. *R\\*,HI *)s   A**A:	c                @    V P                   P                  R R 4       R# )u   colläc                     W8  W8  ,
          # r   r   r   s   &&r   r   @CollationTests.test_create_collation_not_ascii.<locals>.<lambda>-   r   r   N)r   r   r   s   &r   test_create_collation_not_ascii.CollationTests.test_create_collation_not_ascii,   s    !!(,JKr   c                @    ! R  R\         4      pR pV P                  P                  V! R4      V4       V P                  P                  R4      P	                  4       pV P                  V^ ,          ^ ,          R4       V P                  V^,          ^ ,          R4       R# )c                   &   a  ] tR t^0t o R tRtV tR# )CCollationTests.test_create_collation_bad_upper.<locals>.BadUpperStrc                    R # r   r   r   s   &r   upperICollationTests.test_create_collation_bad_upper.<locals>.BadUpperStr.upper1   s    r   r   N)__name__
__module____qualname____firstlineno__r0   __static_attributes____classdictcell____classdict__s   @r   BadUpperStrr.   0   s      r   r:   c                     W8  W8  ,
          ) # r   r   r   s   &&r   r   @CollationTests.test_create_collation_bad_upper.<locals>.<lambda>3   s    15 12r   mycollz
            select x from (
            select 'a' as x
            union
            select 'b' as x
            ) order by x collate mycoll
            baN)r"   r   r   executefetchallr!   )r   r:   r=   results   &   r   test_create_collation_bad_upper.CollationTests.test_create_collation_bad_upper/   s    	# 	 3!!+h"7@!! #   	 	1s+1s+r   c                    R  pV P                   P                  RV4       RpV P                   P                  V4      P                  4       pV P	                  V. RORR7       V P                   P                  RR4       V P                  \        P                  4      ;_uu_ 4       pV P                   P                  V4      P                  4       pRRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                     W8  W8  ,
          ) # r   r   r   s   &&r   r=   5CollationTests.test_collation_is_used.<locals>.mycoll@   s    e&''r   r=   
            select x from (
            select 'a' as x
            union
            select 'b' as x
            union
            select 'c' as x
            ) order by x collate mycoll
            #the expected order was not returnedmsgN"no such collation sequence: mycoll)c)r>   )r?   )
r   r   r@   rA   r!   r   sqliteOperationalErrorr"   r#   )r   r=   sqlrB   r$   s   &    r   test_collation_is_used%CollationTests.test_collation_is_used?   s    	( 	!!(F3 !!#&//1!9B 	 	D 	!!(D1v66772XX%%c*335F 8R\\*,PQ 87s   $*C==D	c                    R  pV P                   P                  RV4       RpV P                   P                  V4      P                  4       pV P	                  V. RORR7       R# )c                 ,    W8  W8  ,
          ) R,          # )   l        r   r   s   &&r   r=   CCollationTests.test_collation_returns_large_integer.<locals>.mycollX   s    e&'%//r   r=   rH   rI   rJ   NrM   r   r   r@   rA   r!   )r   r=   rQ   rB   s   &   r   $test_collation_returns_large_integer3CollationTests.test_collation_returns_large_integerW   s_    	0 	!!(F3 !!#&//1!9B 	 	Dr   c                (   V P                   pVP                  RR 4       VP                  RR 4       VP                  R4      P                  4       pV P	                  V^ ,          ^ ,          R4       V P	                  V^,          ^ ,          R4       R# )zl
Register two different collation functions under the same name.
Verify that the last one is actually used.
r=   c                     W8  W8  ,
          # r   r   r   s   &&r   r   >CollationTests.test_collation_register_twice.<locals>.<lambda>o       QUqu4Er   c                     W8  W8  ,
          ) # r   r   r   s   &&r   r   r]   p   s    qu6G4Hr   zi
            select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
            r>   r?   NrX   )r   r   rB   s   &  r   test_collation_register_twice,CollationTests.test_collation_register_twicei   s~    
 hhX'EFX'HI   	 	1s+1s+r   c                Z   V P                   pVP                  RR 4       VP                  RR4       V P                  \        P                  4      ;_uu_ 4       pVP                  R4       RRR4       V P                  \        XP                  4      R4       R#   + '       g   i     L7; i)z]
Register a collation, then deregister it. Make sure an error is raised if we try
to use it.
r=   c                     W8  W8  ,
          # r   r   r   s   &&r   r   :CollationTests.test_deregister_collation.<locals>.<lambda>}   r^   r   Nz?select 'a' as x union select 'b' as x order by x collate mycollrL   )	r   r   r   rO   rP   r@   r!   r"   r#   )r   r   r$   s   &  r   test_deregister_collation(CollationTests.test_deregister_collationw   s|    
 hhX'EFXt,v66772KKYZ 8R\\*,PQ 87s   BB*	r   N)r2   r3   r4   r5   r   r%   r*   rC   rR   rY   r`   re   r6   r7   r8   s   @r   r
   r
   !   s9     LJ
L, R0D$,
R 
Rr   r
   c                   ~   a  ] tR t^t o R tR tR tR t]! ]	RR7      R 4       t
]! ]	RR7      R 4       tR	 tR
tV tR# )ProgressTestsc                   a . oV3R lpV P                   P                  V^4       V P                   P                  R4       V P                  S4       R# )z;
Test that the progress handler is invoked once it is set.
c                  *   < S P                  R 4       ^ # r   appendprogress_callss   r   progress:ProgressTests.test_progress_handler_used.<locals>.progress       !!$'r   z0
            create table foo(a, b)
            N)r   set_progress_handlerr@   
assertTrue)r   ro   rn   s   & @r   test_progress_handler_used(ProgressTests.test_progress_handler_used   sJ     	 	%%h2  	 	'r   c                .  a V P                   p. oV3R lpVP                  V^4       VP                  4       pVP                  R4       \	        S4      p. oVP                  V^4       VP                  R4       \	        S4      pV P                  WE4       R# )z-
Test that the opcode argument is respected.
c                  *   < S P                  R 4       ^ # r   rk   rm   s   r   ro   1ProgressTests.test_opcode_count.<locals>.progress   rq   r   z1
            create table foo (a, b)
            z1
            create table bar (a, b)
            N)r   rr   cursorr@   lenassertGreaterEqual)r   r   ro   cursfirst_countsecond_countrn   s   &     @r   test_opcode_countProgressTests.test_opcode_count   s     hh	 	  1-zz|  	 .)  1-  	 >*:r   c                    R pV P                   P                  V^4       V P                   P                  4       pV P                  \        P
                  VP                  R4       R# )zG
Test that returning a non-zero value stops the operation in progress.
c                      ^#    r   r   r   r   ro   5ProgressTests.test_cancel_operation.<locals>.progress   s    r   zcreate table bar (a, b)N)r   rr   ry   r   rO   rP   r@   )r   ro   r|   s   &  r   test_cancel_operation#ProgressTests.test_cancel_operation   sL    	%%h2xx ##LL%	'r   c                   a V P                   p^ oV3R lpVP                  V^4       VP                  R^4       VP                  R4      P                  4        V P	                  S^ R4       R# )zS
Test that setting the progress handler to None clears the previously set handler.
c                     < ^o ^ # r   r   )actions   r   ro   2ProgressTests.test_clear_handler.<locals>.progress   s    Fr   Nz&select 1 union select 2 union select 3z progress handler was not cleared)r   rr   r@   rA   r!   )r   r   ro   r   s   &  @r   test_clear_handler ProgressTests.test_clear_handler   sc     hh	 	  1-  q)<=FFH$FGr   bad_progress)	msg_regexc                   R  pV P                   P                  V^4       V P                  \        P                  4      ;_uu_ 4        V P                   P                  R4       RRR4       R#   + '       g   i     R# ; i)c                      ^^ ,           R# r   Nr   r   r   r   r   BProgressTests.test_error_in_progress_handler.<locals>.bad_progress   s    EEr   8
                create table foo(a, b)
                Nr   rr   r   rO   rP   r@   )r   r   s   & r   test_error_in_progress_handler,ProgressTests.test_error_in_progress_handler   sX    	%%lA6v6677HH   8777s   A--A>	c                  a  ! R  R4      oV3R lpV P                   P                  V^4       V P                  \        P                  4      ;_uu_ 4        V P                   P                  R4       RRR4       R#   + '       g   i     R# ; i)c                   &   a  ] tR t^t o R tRtV tR# )DProgressTests.test_error_in_progress_handler_result.<locals>.BadBoolc                    ^^ ,           R# r   r   r   s   &r   __bool__MProgressTests.test_error_in_progress_handler_result.<locals>.BadBool.__bool__   s    Ar   r   N)r2   r3   r4   r5   r   r6   r7   r8   s   @r   BadBoolr      s      r   r   c                     < S ! 4       # r   r   )r   s   r   r   IProgressTests.test_error_in_progress_handler_result.<locals>.bad_progress   s    9r   r   Nr   )r   r   r   s   & @r   %test_error_in_progress_handler_result3ProgressTests.test_error_in_progress_handler_result   sc    	 		%%lA6v6677HH   8777s   A;;B	c                    R pV P                  \        V4      ;_uu_ 4       pV P                  P                  R ^R7       RRR4       V P	                  XP
                  \        4       R#   + '       g   i     L2; i)zPassing keyword argument 'progress_handler' to _sqlite3.Connection.set_progress_handler\(\) is deprecated. Parameter 'progress_handler' will become positional-only in Python 3.15.c                      R # r   r   r   r   r   r   BProgressTests.test_progress_handler_keyword_args.<locals>.<lambda>   s    4r   )progress_handlernN)assertWarnsRegexDeprecationWarningr   rr   r!   filename__file__r   regexr$   s   &  r   "test_progress_handler_keyword_args0ProgressTests.test_progress_handler_keyword_args   s]     	 ""#5u==HH))<1)M >h/ >=s   A**A:	r   N)r2   r3   r4   r5   rt   r   r   r   r   ZeroDivisionErrorr   r   r   r6   r7   r8   s   @r   rh   rh      s^     (;.'H &.A B &.A
 B

0 
0r   rh   c                      a  ] tR t^t o ]P
                  R 4       tR tR tR t	R t
R t]! ]P                  RR7      R	 4       t]! ]R
R7      R 4       tR tRtV tR# )TraceCallbackTestsc              #     a"    . oVP                  V3R  l4       Rx  V P                  SV4       VP                  R4       R#   T P                  ST4       TP                  R4       i ; i5i)c                 &   < SP                  V 4      # r   rk   )stmttraceds   &r   r   5TraceCallbackTests.check_stmt_trace.<locals>.<lambda>   s    v}}T/Br   N)set_trace_callbackr!   )r   cxexpectedr   s   &&&@r   check_stmt_trace#TraceCallbackTests.check_stmt_trace   sa     	(F!!"BCVX.!!$' VX.!!$'s   A-A %A-%A**A-c                D  a . oV3R lpV P                   P                  V4       V P                   P                  R4       V P                  S4       T P                  \        ;QJ d(    R S 4       F  '       g   K   R4       R# 	  R4       R# ! R S 4       4      4       R# )z9
Test that the trace callback is invoked once it is set.
c                 *   < SP                  V 4       R # r   rk   	statementtraced_statementss   &r   trace:TraceCallbackTests.test_trace_callback_used.<locals>.trace       $$Y/r   create table foo(a, b)c              3   ,   "   T F
  pR V9   x  K  	  R# 5i)zcreate table fooNr   ).0r   s   & r   	<genexpr>>TraceCallbackTests.test_trace_callback_used.<locals>.<genexpr>  s     UCT4.$6CTs   TFN)r   r   r@   rs   any)r   r   r   s   & @r   test_trace_callback_used+TraceCallbackTests.test_trace_callback_used   ss     	0##E*12)*UCTUVVUCTUUVr   c                   a V P                   p. oV3R lpVP                  V4       VP                  R4       VP                  R4       V P                  SR4       R# )zR
Test that setting the trace callback to None clears the previously set callback.
c                 *   < SP                  V 4       R # r   rk   r   s   &r   r   ;TraceCallbackTests.test_clear_trace_callback.<locals>.trace	  r   r   Nr   ztrace callback was not cleared)r   r   r@   assertFalse)r   r   r   r   s   &  @r   test_clear_trace_callback,TraceCallbackTests.test_clear_trace_callback  sT     hh	0u%t$,-*,LMr   c                  aa RoV P                   p. oV3R lpVP                  V4       VP                  R4       VP                  RS,          4       VP                  4        T P	                  \
        ;QJ d    V3R lS 4       F  '       g   K   RM	  RM! V3R lS 4       4      R\        S4      : R	R
P                  \        \        S4      4      : 24       R# )z7
Test that the statement can contain unicode literals.
u   öäüÖÄÜß€c                 *   < SP                  V 4       R # r   rk   r   s   &r   r   6TraceCallbackTests.test_unicode_content.<locals>.trace  r   r   create table foo(x)z insert into foo(x) values ('%s')c              3   .   <"   T F
  pSV9   x  K  	  R # 5ir   r   )r   r   unicode_values   & r   r   :TraceCallbackTests.test_unicode_content.<locals>.<genexpr>  s     P>OdMT1>Os   TFzUnicode data z garbled in trace callback: z, N)	r   r   r@   commitrs   r   asciijoinmap)r   r   r   r   r   s   &  @@r   test_unicode_content'TraceCallbackTests.test_unicode_content  s     =hh	0u%)*6FG

P>OPP>OPP /3uFW;X1Y[	\r   c                4  a . oV3R  lpRR.pV P                  \        \        4       \        P                  ! \        RR7      p\        P                  ! \        4      p VP                  V4       VP                  4       pVP                  V^ ,          4       VP                  R4       VP                  V^,          4       VP                  4        VP                  4        V P                  SV4       R#   TP                  4        TP                  4        i ; i)c                 *   < SP                  V 4       R # r   rk   r   s   &r   r   =TraceCallbackTests.test_trace_callback_content.<locals>.trace$  r   r   r   zinsert into foo(x) values(1)N)isolation_levelzcreate table bar(x))

addCleanupr   r   rO   connectr   ry   r@   closer!   )r   r   queriescon1con2curr   s   &     @r   test_trace_callback_content.TraceCallbackTests.test_trace_callback_content!  s    	0 )13'~~fd;~~f%	##E*++-CKK
#LL./KK
#JJLJJL*G4 JJLJJLs   A"C5 5"Dc                   . ROp\        4       ;_uu_ 4       q P                  W!4      ;_uu_ 4        V;_uu_ 4        VP                  R 4       VP                  RR \	        ^4       4       4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)create table t(t)zinsert into t values(?)c              3   &   "   T F  q3x  K	  	  R # 5ir   r   )r   vs   & r   r   =TraceCallbackTests.test_trace_expanded_sql.<locals>.<genexpr>C  s     :RA4s   N)r   zBEGIN zinsert into t values(0)zinsert into t values(1)zinsert into t values(2)COMMIT)r   r   r@   executemanyrange)r   r   r   s   &  r   test_trace_expanded_sql*TraceCallbackTests.test_trace_expanded_sql7  sz    
 "&;&;B&I&I

./8:Rq:RS  'J 'J&Is9   B/B	4B	/B	7B/	BB	B,'B//C 	z5Expanded SQL string exceeds the maximum string length)r   c                D   R p\         P                  p\        4       ;_uu_ 4       p\        W2R7      ;_uu_ 4       pRpRV,          pVR,           pV.pV P	                  W84      ;_uu_ 4        VP                  Wv34       RRR4       V RV R2p	V P	                  W9.4      ;_uu_ 4        VP                  Wu34       RRR4       RRR4       RRR4       R#   + '       g   i     L_; i  + '       g   i     L5; i  + '       g   i     L@; i  + '       g   i     R# ; i)zselect 1 as a where a=)categoryr?   ?N')rO   SQLITE_LIMIT_LENGTHr   r   r   r@   )
r   templater   r   limok_param	bad_paramunexpanded_queryr   expanded_querys
   &         r    test_trace_too_much_expanded_sql3TraceCallbackTests.test_trace_too_much_expanded_sqlE  s     ,--"hr&E&EHc	I'#~()H&&r44

+\: 5 !)z8*A6N&&r+;<<

+[9 = 'F 54 =< 'F&EsR   D1C;	+C>*C;	(C(;C;	DC% C;	(C83C;	;DDD	zdivision by zeroc                    \        4       ;_uu_ 4       pVP                  R  4       VP                  R4       RRR4       R#   + '       g   i     R# ; i)c                     ^^ ,          # )   r   )r   s   &r   r   ;TraceCallbackTests.test_trace_bad_handler.<locals>.<lambda>`  s    qsr   zselect 1N)r   r   r@   )r   r   s   & r   test_trace_bad_handler)TraceCallbackTests.test_trace_bad_handler]  s7    "!!"23JJz" s   $AA	c                    R pV P                  \        V4      ;_uu_ 4       pV P                  P                  R R7       RRR4       V P	                  XP
                  \        4       R#   + '       g   i     L2; i)zPassing keyword argument 'trace_callback' to _sqlite3.Connection.set_trace_callback\(\) is deprecated. Parameter 'trace_callback' will become positional-only in Python 3.15.c                      R # r   r   r   r   r   r   <TraceCallbackTests.test_trace_keyword_args.<locals>.<lambda>l  s    tr   )trace_callbackN)r   r   r   r   r!   r   r   r   s   &  r   test_trace_keyword_args*TraceCallbackTests.test_trace_keyword_argsc  s[     	 ""#5u==HH''|'D >h/ >=s   A))A9	r   N)r2   r3   r4   r5   
contextlibcontextmanagerr   r   r   r   r   r   r   rO   	DataErrorr  r   r  r  r6   r7   r8   s   @r   r   r      s     ( (
WN\"5,T E:	:( &.@A# B#

0 
0r   r   __main__)r  sqlite3rO   unittesttest.support.os_helperr   r   utilr   r   r   r   TestCaser
   rh   r   r2   mainr   r   r   <module>r     s~   .    1 < < %`R((*;*; `RFd0'):): d0NB0,h.?.? B0J zMMO r   