HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/sqlite3/test/__pycache__/userfunctions.cpython-37.opt-1.pyc
B

��g;�@s�ddlZddlZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZGd d!�d!�ZGd"d#�d#�ZGd$d%�d%�ZGd&d'�d'�ZGd(d)�d)�ZGd*d+�d+�ZGd,d-�d-�ZGd.d/�d/�ZGd0d1�d1ej�ZGd2d3�d3ej�ZGd4d5�d5ej�ZGd6d7�d7e�ZGd8d9�d9e�ZGd:d;�d;e�Z d<d=�Z!d>d?�Z"e#d@k�r~e"�dS)A�NcCsdS)N�foo�rrr�6/usr/local/lib/python3.7/sqlite3/test/userfunctions.py�func_returntextsrcCsdS)N�barrrrrr�func_returnunicodesrcCsdS)N�*rrrrr�func_returnint sr	cCsdS)Ng��Q�	@rrrrr�func_returnfloat"sr
cCsdS)Nrrrrr�func_returnnull$srcCsdS)Nsblobrrrrr�func_returnblob&srcCsdS)Nlrrrrr�func_returnlonglong(sr
cCsdddS)N�rrrrrr�func_raiseexception*srcCst|�tkS)N)�type�str)�vrrr�
func_isstring-srcCst|�tkS)N)r�int)rrrr�
func_isint/srcCst|�tkS)N)r�float)rrrr�func_isfloat1srcCst|�td�kS)N)r)rrrr�func_isnone3srcCst|ttf�S)N)�
isinstance�bytes�
memoryview)rrrr�func_isblob5srcCst|t�o|dkS)Nl)rr)rrrr�func_islonglong7srcGst|�S)N)�len)�argsrrr�func:sr c@seZdZdd�Zdd�ZdS)�
AggrNoStepcCsdS)Nr)�selfrrr�__init__>szAggrNoStep.__init__cCsdS)N�r)r"rrr�finalizeAszAggrNoStep.finalizeN)�__name__�
__module__�__qualname__r#r%rrrrr!=sr!c@seZdZdd�Zdd�ZdS)�AggrNoFinalizecCsdS)Nr)r"rrrr#EszAggrNoFinalize.__init__cCsdS)Nr)r"�xrrr�stepHszAggrNoFinalize.stepN)r&r'r(r#r+rrrrr)Dsr)c@s$eZdZdd�Zdd�Zdd�ZdS)�AggrExceptionInInitcCsdddS)Nrrr)r"rrrr#LszAggrExceptionInInit.__init__cCsdS)Nr)r"r*rrrr+OszAggrExceptionInInit.stepcCsdS)Nr)r"rrrr%RszAggrExceptionInInit.finalizeN)r&r'r(r#r+r%rrrrr,Ksr,c@s$eZdZdd�Zdd�Zdd�ZdS)�AggrExceptionInStepcCsdS)Nr)r"rrrr#VszAggrExceptionInStep.__init__cCsdddS)Nrrr)r"r*rrrr+YszAggrExceptionInStep.stepcCsdS)Nrr)r"rrrr%\szAggrExceptionInStep.finalizeN)r&r'r(r#r+r%rrrrr-Usr-c@s$eZdZdd�Zdd�Zdd�ZdS)�AggrExceptionInFinalizecCsdS)Nr)r"rrrr#`sz AggrExceptionInFinalize.__init__cCsdS)Nr)r"r*rrrr+cszAggrExceptionInFinalize.stepcCsdddS)Nrrr)r"rrrr%fsz AggrExceptionInFinalize.finalizeN)r&r'r(r#r+r%rrrrr._sr.c@s$eZdZdd�Zdd�Zdd�ZdS)�
AggrCheckTypecCs
d|_dS)N)�val)r"rrrr#jszAggrCheckType.__init__cCs.ttttd�td�}t||t|�k�|_dS)N)rrr�None�blob)rrrrrr0)r"�	whichTyper0�theTyperrrr+mszAggrCheckType.stepcCs|jS)N)r0)r"rrrr%rszAggrCheckType.finalizeN)r&r'r(r#r+r%rrrrr/isr/c@s$eZdZdd�Zdd�Zdd�ZdS)�AggrCheckTypescCs
d|_dS)Nr)r0)r"rrrr#vszAggrCheckTypes.__init__cGsDttttd�td�}x*|D]"}|jt||t|�k�7_qWdS)N)rrrr1r2)rrrrrr0)r"r3Zvalsr4r0rrrr+ys
zAggrCheckTypes.stepcCs|jS)N)r0)r"rrrr%szAggrCheckTypes.finalizeN)r&r'r(r#r+r%rrrrr5usr5c@s$eZdZdd�Zdd�Zdd�ZdS)�AggrSumcCs
d|_dS)Ng)r0)r"rrrr#�szAggrSum.__init__cCs|j|7_dS)N)r0)r"r0rrrr+�szAggrSum.stepcCs|jS)N)r0)r"rrrr%�szAggrSum.finalizeN)r&r'r(r#r+r%rrrrr6�sr6c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'S)(�
FunctionTestscCst�d�|_|j�ddt�|j�ddt�|j�ddt�|j�ddt�|j�ddt�|j�ddt	�|j�d	dt
�|j�d
dt�|j�ddt�|j�d
dt
�|j�ddt�|j�ddt�|j�ddt�|j�ddt�|j�ddt�dS)Nz:memory:Z
returntextrZ
returnunicodeZ	returnintZreturnfloatZ
returnnullZ
returnblobZreturnlonglongZraiseexception�isstringr$ZisintZisfloatZisnoneZisblobZ
islonglongZspam���)�sqlite�connect�con�create_functionrrr	r
rrr
rrrrrrrr )r"rrr�setUp�s zFunctionTests.setUpcCs|j��dS)N)r<�close)r"rrr�tearDown�szFunctionTests.tearDownc	Cs0|�tj��|j�dddd��WdQRXdS)N�blai����cSsd|S)N�r)r*rrr�<lambda>��z6FunctionTests.CheckFuncErrorOnCreate.<locals>.<lambda>)�assertRaisesr:�OperationalErrorr<r=)r"rrr�CheckFuncErrorOnCreate�sz$FunctionTests.CheckFuncErrorOnCreatecCs@dd�}|�}|t�d<|j�dd|�|j��}|�d�dS)NcSsdd�}|S)NcSsdS)Nr$rrrrr�f�sz;FunctionTests.CheckFuncRefCount.<locals>.getfunc.<locals>.fr)rHrrr�getfunc�sz0FunctionTests.CheckFuncRefCount.<locals>.getfuncrZreftestrzselect reftest())�globalsr<r=�cursor�execute)r"rIrH�currrr�CheckFuncRefCount�s

zFunctionTests.CheckFuncRefCountcCs@|j��}|�d�|��d}|�t|�t�|�|d�dS)Nzselect returntext()rr)r<rKrL�fetchone�assertEqualrr)r"rMr0rrr�CheckFuncReturnText�s


z!FunctionTests.CheckFuncReturnTextcCs@|j��}|�d�|��d}|�t|�t�|�|d�dS)Nzselect returnunicode()rr)r<rKrLrOrPrr)r"rMr0rrr�CheckFuncReturnUnicode�s


z$FunctionTests.CheckFuncReturnUnicodecCs@|j��}|�d�|��d}|�t|�t�|�|d�dS)Nzselect returnint()rr)r<rKrLrOrPrr)r"rMr0rrr�CheckFuncReturnInt�s


z FunctionTests.CheckFuncReturnIntcCsN|j��}|�d�|��d}|�t|�t�|dks@|dkrJ|�d�dS)Nzselect returnfloat()rg�&1�	@gT㥛� 	@zwrong value)r<rKrLrOrPrrZfail)r"rMr0rrr�CheckFuncReturnFloat�s

z"FunctionTests.CheckFuncReturnFloatcCsD|j��}|�d�|��d}|�t|�td��|�|d�dS)Nzselect returnnull()r)r<rKrLrOrPr)r"rMr0rrr�CheckFuncReturnNull�s


z!FunctionTests.CheckFuncReturnNullcCs@|j��}|�d�|��d}|�t|�t�|�|d�dS)Nzselect returnblob()rsblob)r<rKrLrOrPrr)r"rMr0rrr�CheckFuncReturnBlob�s


z!FunctionTests.CheckFuncReturnBlobcCs0|j��}|�d�|��d}|�|d�dS)Nzselect returnlonglong()rl)r<rKrLrOrP)r"rMr0rrr�CheckFuncReturnLongLong�s

z%FunctionTests.CheckFuncReturnLongLongc	CsJ|j��}|�tj��}|�d�|��WdQRX|�t|j	�d�dS)Nzselect raiseexception()z&user-defined function raised exception)
r<rKrEr:rFrLrOrPr�	exception)r"rM�cmrrr�CheckFuncException�s


z FunctionTests.CheckFuncExceptioncCs2|j��}|�dd�|��d}|�|d�dS)Nzselect isstring(?))rrr$)r<rKrLrOrP)r"rMr0rrr�CheckParamString�s
zFunctionTests.CheckParamStringcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect isint(?))rrr$)r<rKrLrOrP)r"rMr0rrr�
CheckParamInt�s
zFunctionTests.CheckParamIntcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect isfloat(?))g��Q�	@rr$)r<rKrLrOrP)r"rMr0rrr�CheckParamFloat�s
zFunctionTests.CheckParamFloatcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect isnone(?))Nrr$)r<rKrLrOrP)r"rMr0rrr�CheckParamNone�s
zFunctionTests.CheckParamNonecCs8|j��}|�dtd�f�|��d}|�|d�dS)Nzselect isblob(?)sblobrr$)r<rKrLrrOrP)r"rMr0rrr�CheckParamBlobs
zFunctionTests.CheckParamBlobcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect islonglong(?))lrr$)r<rKrLrOrP)r"rMr0rrr�CheckParamLongLong
s
z FunctionTests.CheckParamLongLongcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect spam(?, ?))r$rBrrB)r<rKrLrOrP)r"rMr0rrr�CheckAnyArgumentss
zFunctionTests.CheckAnyArgumentsN)r&r'r(r>r@rGrNrQrRrSrTrUrVrWrZr[r\r]r^r_r`rarrrrr7�s&r7c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �AggregateTestsc	Cs�t�d�|_|j��}|�d�|�dddddtd�f�|j�dd	t�|j�d
d	t�|j�dd	t	�|j�dd	t
�|j�d
d	t�|j�ddt�|j�ddt
�|j�dd	t�dS)Nz:memory:z�
            create table test(
                t text,
                i integer,
                f float,
                n,
                b blob
                )
            z6insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)rrg��Q�	@sblobZnostepr$Z
nofinalizeZexcInitZexcStepZexcFinalizeZ	checkTyperBZ
checkTypesr9Zmysum)r:r;r<rKrLrZcreate_aggregater!r)r,r-r.r/r5r6)r"rMrrrr>s
zAggregateTests.setUpcCsdS)Nr)r"rrrr@0szAggregateTests.tearDownc	Cs,|�tj��|j�ddt�WdQRXdS)NrAi����)rEr:rFr<r=r6)r"rrr�CheckAggrErrorOnCreate5sz%AggregateTests.CheckAggrErrorOnCreatec	Cs@|j��}|�t��}|�d�WdQRX|�t|j�d�dS)Nzselect nostep(t) from testz+'AggrNoStep' object has no attribute 'step')r<rKrE�AttributeErrorrLrPrrX)r"rMrYrrr�CheckAggrNoStep9s
zAggregateTests.CheckAggrNoStepc	CsN|j��}|�tj��}|�d�|��d}WdQRX|�t|j	�d�dS)Nzselect nofinalize(t) from testrz7user-defined aggregate's 'finalize' method raised error)
r<rKrEr:rFrLrOrPrrX)r"rMrYr0rrr�CheckAggrNoFinalize?s


z"AggregateTests.CheckAggrNoFinalizec	CsN|j��}|�tj��}|�d�|��d}WdQRX|�t|j	�d�dS)Nzselect excInit(t) from testrz7user-defined aggregate's '__init__' method raised error)
r<rKrEr:rFrLrOrPrrX)r"rMrYr0rrr�CheckAggrExceptionInInitFs


z'AggregateTests.CheckAggrExceptionInInitc	CsN|j��}|�tj��}|�d�|��d}WdQRX|�t|j	�d�dS)Nzselect excStep(t) from testrz3user-defined aggregate's 'step' method raised error)
r<rKrEr:rFrLrOrPrrX)r"rMrYr0rrr�CheckAggrExceptionInStepMs


z'AggregateTests.CheckAggrExceptionInStepc	CsN|j��}|�tj��}|�d�|��d}WdQRX|�t|j	�d�dS)Nzselect excFinalize(t) from testrz7user-defined aggregate's 'finalize' method raised error)
r<rKrEr:rFrLrOrPrrX)r"rMrYr0rrr�CheckAggrExceptionInFinalizeTs


z+AggregateTests.CheckAggrExceptionInFinalizecCs2|j��}|�dd�|��d}|�|d�dS)Nzselect checkType('str', ?))rrr$)r<rKrLrOrP)r"rMr0rrr�CheckAggrCheckParamStr[s
z%AggregateTests.CheckAggrCheckParamStrcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect checkType('int', ?))rrr$)r<rKrLrOrP)r"rMr0rrr�CheckAggrCheckParamIntas
z%AggregateTests.CheckAggrCheckParamIntcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect checkTypes('int', ?, ?))r�rrB)r<rKrLrOrP)r"rMr0rrr�CheckAggrCheckParamsIntgs
z&AggregateTests.CheckAggrCheckParamsIntcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect checkType('float', ?))g��Q�	@rr$)r<rKrLrOrP)r"rMr0rrr�CheckAggrCheckParamFloatms
z'AggregateTests.CheckAggrCheckParamFloatcCs2|j��}|�dd�|��d}|�|d�dS)Nzselect checkType('None', ?))Nrr$)r<rKrLrOrP)r"rMr0rrr�CheckAggrCheckParamNoness
z&AggregateTests.CheckAggrCheckParamNonecCs8|j��}|�dtd�f�|��d}|�|d�dS)Nzselect checkType('blob', ?)sblobrr$)r<rKrLrrOrP)r"rMr0rrr�CheckAggrCheckParamBlobys
z&AggregateTests.CheckAggrCheckParamBlobcCsL|j��}|�d�|�ddddg�|�d�|��d}|�|d�dS)	Nzdelete from testzinsert into test(i) values (?))�
)�)�zselect mysum(i) from testr�<)r<rKrLZexecutemanyrOrP)r"rMr0rrr�CheckAggrCheckAggrSums


z$AggregateTests.CheckAggrCheckAggrSumN)r&r'r(r>r@rcrerfrgrhrirjrkrmrnrorprurrrrrbsrbc@s8eZdZedd��Zdd�Zdd�Zdd�Zd	d
�ZdS)�AuthorizerTestscCs,|tjkrtjS|dks |dkr&tjStjS)N�c2�t2)r:�
SQLITE_SELECTZSQLITE_DENY�	SQLITE_OK)�action�arg1�arg2�dbname�sourcerrr�
authorizer_cb�s

zAuthorizerTests.authorizer_cbcCs6t�d�|_|j�d�|j�d�|j�|j�dS)Nz:memory:z�
            create table t1 (c1, c2);
            create table t2 (c1, c2);
            insert into t1 (c1, c2) values (1, 2);
            insert into t2 (c1, c2) values (4, 5);
            zselect c2 from t2)r:r;r<Z
executescriptrLZset_authorizerr�)r"rrrr>�s
zAuthorizerTests.setUpcCsdS)Nr)r"rrrr@�szAuthorizerTests.tearDownc	Cs:|�tj��}|j�d�WdQRX|�dt|j��dS)Nzselect * from t2�
prohibited)rEr:�
DatabaseErrorr<rL�assertInrrX)r"rYrrr�test_table_access�sz!AuthorizerTests.test_table_accessc	Cs:|�tj��}|j�d�WdQRX|�dt|j��dS)Nzselect c2 from t1r�)rEr:r�r<rLr�rrX)r"rYrrr�test_column_access�sz"AuthorizerTests.test_column_accessN)	r&r'r(�staticmethodr�r>r@r�r�rrrrrv�s
rvc@seZdZedd��ZdS)�AuthorizerRaiseExceptionTestscCs(|tjkrt�|dks|dkr"t�tjS)Nrwrx)r:ry�
ValueErrorrz)r{r|r}r~rrrrr��s

z+AuthorizerRaiseExceptionTests.authorizer_cbN)r&r'r(r�r�rrrrr��sr�c@seZdZedd��ZdS)�AuthorizerIllegalTypeTestscCs(|tjkrdS|dks|dkr"dStjS)Ngrwrx)r:ryrz)r{r|r}r~rrrrr��s

z(AuthorizerIllegalTypeTests.authorizer_cbN)r&r'r(r�r�rrrrr��sr�c@seZdZedd��ZdS)�AuthorizerLargeIntegerTestscCs(|tjkrdS|dks|dkr"dStjS)Nlrwrx)r:ryrz)r{r|r}r~rrrrr��s

z)AuthorizerLargeIntegerTests.authorizer_cbN)r&r'r(r�r�rrrrr��sr�c
CsJt�td�}t�td�}t�t�}t�|||t�t�t�t�t�t�f�S)NZCheck)	�unittestZ	makeSuiter7rbrvZ	TestSuiter�r�r�)Zfunction_suiteZaggregate_suiteZauthorizer_suiterrr�suite�s
r�cCst��}|�t��dS)N)r�ZTextTestRunner�runr�)Zrunnerrrr�test�sr��__main__)$r�Zsqlite3r:rrr	r
rrr
rrrrrrrr r!r)r,r-r.r/r5r6ZTestCaser7rbrvr�r�r�r�r�r&rrrr�<module>sF




p$