Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/testing/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/testing/__pycache__/engines.cpython-311.pyc

�

�܋f )��t�ddlmZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZGd
�de��Z
e
��Zd�Ze	d
���Ze	d���Ze	d���Ze	d���Zdd�ZGd�de��Zdd�Zdd�Zdd�ZGd�de��ZGd�de��Zeefd�ZdS)�)�absolute_importN�)�config)�uses_deprecated)�	decorator�)�event)�poolc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
��d���Ze
��d���Zd
�ZdS)�ConnectionKillerc��tj��|_tj��|_t	��|_dS�N)�weakref�WeakKeyDictionary�
proxy_refs�testing_engines�set�conns��selfs �m/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/sqlalchemy/testing/engines.py�__init__zConnectionKiller.__init__s2��!�3�5�5���&�8�:�:����U�U��
�
�
�c��d|j|<dS�NT)r)r�engines  r�
add_enginezConnectionKiller.add_engines��'+���V�$�$�$rc�>�|j�||f��dSr)r�add)r�
dbapi_conn�
con_records   r�connectzConnectionKiller.connects!���
���
�J�/�0�0�0�0�0rc��d|j|<dSr)r)r�	dbapi_conr!�	con_proxys    r�checkoutzConnectionKiller.checkout!s��%)���	�"�"�"rc�>�|j�||f��dSr)r�discard)rr$r!�	exceptions    r�
invalidatezConnectionKiller.invalidate$s#���
���I�z�2�3�3�3�3�3rc�z�	|��dS#t$r"}tjd|z��Yd}~dSd}~wwxYw)Nz5testing_reaper couldn't rollback/close connection: %s��	Exception�warnings�warn�r�fn�es   r�_safezConnectionKiller._safe'so��	��B�D�D�D�D�D���	�	�	��M�J�Q�N�
�
�
�
�
�
�
�
�
�����	�����
�
:�5�:c�z�t|j��D]%}|�!|jr|�|j���&dSr)�listr�is_validr3�rollback�r�recs  r�rollback_allzConnectionKiller.rollback_all/sE�����(�(�	)�	)�C���3�<���
�
�3�<�(�(�(��	)�	)rc�z�t|j��D]%}|�!|jr|�|j���&dSr)r6rr7r3�_closer9s  r�	close_allzConnectionKiller.close_all4sE�����(�(�	'�	'�C���3�<���
�
�3�:�&�&�&��	'�	'rc�~�t|j��D]'\}}|j��
|�|j���(dSr)r6r�
connectionr3r8�r�connr:s   r�_after_test_ctxz ConnectionKiller._after_test_ctx9sO���d�j�)�)�	&�	&�I�D�#��~�%�
��J�J�t�}�%�%�%�%�	&�	&rc�|�tjjr|���dS|���dSr)r�options�low_connections�_stop_test_ctx_minimal�_stop_test_ctx_aggressivers r�_stop_test_ctxzConnectionKiller._stop_test_ctxHs?���>�)�	-��'�'�)�)�)�)�)��*�*�,�,�,�,�,rc���|���t��|_t|j��D]$}|t
jur|����%dSr)r>rrr6rr�db�disposer9s  rrGz'ConnectionKiller._stop_test_ctx_minimalNs\���������U�U��
���,�-�-�	�	�C��&�)�#�#����
�
�
��	�	rc� �|���t|j��D]&\}}|�|j��d|_�'t
��|_t|j��D]}|����dSr)	r>r6rr3�closer@rrrLrAs   rrHz*ConnectionKiller._stop_test_ctx_aggressiveXs����������d�j�)�)�	"�	"�I�D�#��J�J�t�z�"�"�"�!�C�N�N��U�U��
���,�-�-�	�	�C��K�K�M�M�M�M�	�	rc�,�|jD]}|jrJ��dSr)rr7r9s  r�assert_all_closedz"ConnectionKiller.assert_all_closedcs1���?�	�	�C��|�
��u�
�	�	rN)�__name__�
__module__�__qualname__rrr"r&r*r3r;r>rCrIrrGrHrP�rrrrs���������
,�,�,�1�1�1�*�*�*�4�4�4����)�)�)�
'�'�'�

&�
&�
&�-�-�-��_���������_������������rrc�p�t���t|d��r|���tjjjsMddlm	}|�
dd���5|�|��ddd��dS#1swxYwYdS|�|��dS)NrNr)�
assertionszCan't sort tablesF)�assert_)�testing_reaperr>�hasattrrNrrK�dialect�supports_alter�rV�expect_warnings�drop_all)�metadata�bindrVs   r�drop_all_tablesrals���������t�W�����
�
�����9��+� � � � � � � �
�
'�
'�(;�U�
'�
K�
K�	$�	$����d�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$�	���$�����s�1B�B�Bc��	||i|��t���dS#t���wxYwr)rXrP�r1�args�kws   r�assert_conns_closedrfzsH��+�
��D��B�����(�(�*�*�*�*�*���(�(�*�*�*�*����	�%�Ac��	||i|��t���dS#t���wxYw)zBDecorator that rolls back all open connections after fn execution.N)rXr;rcs   r�rollback_open_connectionsri�sH��&�
��D��B�����#�#�%�%�%�%�%���#�#�%�%�%�%���rgc�H�t���||i|��dS)z:Decorator that closes all connections before fn execution.N�rXr>rcs   r�close_firstrl�s+���������B��O��O�O�O�O�Orc��	||i|��t���dS#t���wxYw)z9Decorator that closes all connections after fn execution.Nrkrcs   r�close_open_connectionsrn�sH��#�
��D��B����� � �"�"�"�"�"��� � �"�"�"�"���rgc#��K�ddlm}|jD]W}|r||vr�	t||d��}|s%tt	d|z��j|��}|���V��XdS)Nrzsqlalchemy.databases.%s)�sqlalchemy.databases�	databases�__all__�getattr�
__import__rZ)�exclude�d�name�mods    r�all_dialectsry�s�����$�$�$�$�$�$��	�	�	���	�t�w�����a��t�$�$���	���4�t�;�<�<�F����C��k�k�m�m�����	�	rc�4�eZdZd�Zd�Zd�Zd�Zd	d�Zd�ZdS)
�ReconnectFixturec�0�||_g|_d|_dS�NF)�dbapi�connections�
is_stopped)rr~s  rrzReconnectFixture.__init__�s����
��������rc�,�t|j|��Sr)rsr~�r�keys  r�__getattr__zReconnectFixture.__getattr__�s���t�z�3�'�'�'rc��|jj|i|��}|jrM|�|j��|���}|�d��Jd���|j�|��|S)Nzselect 1Fz%simulated connect failure didn't work)	r~r"r�r3rN�cursor�executer�append)rrd�kwargsrB�curss     rr"zReconnectFixture.connect�s���!�t�z�!�4�2�6�2�2���?�		��J�J�t�z�"�"�"��;�;�=�=�D�
�L�L��$�$�$�A�A�A�A�5���#�#�D�)�)�)��Krc�z�	|��dS#t$r"}tjd|z��Yd}~dSd}~wwxYw)Nz.ReconnectFixture couldn't close connection: %sr,r0s   rr3zReconnectFixture._safe�so��	��B�D�D�D�D�D���	�	�	��M�C�a�G�
�
�
�
�
�
�
�
�
�����	���r4Fc��||_t|j��D]}|�|j���g|_dSr)r�r6rr3rN)r�stop�cs   r�shutdownzReconnectFixture.shutdown�sJ������d�&�'�'�	 �	 �A��J�J�q�w���������rc��d|_dSr})r�rs r�restartzReconnectFixture.restart�s
������rN)F)	rQrRrSrr�r"r3r�r�rTrrr{r{�ss������ � � �
(�(�(�������	�	�	�	� � � � � rr{c�(���|ptjj}tjjj}|si}t|��|d<t
||����j���fd�}�jjj�_	�jjj
�_|�_�S)N�modulec�z���jj���d�jj_���dSr})rZr~r�r�)�_disposers��rrLz$reconnecting_engine.<locals>.dispose�s6������%�%�'�'�'�*/����'���
�
�
�
�
r)rrK�urlrZr~r{�testing_enginerLr��
test_shutdownr��test_restart)r�rEr~rLr�rs    @@r�reconnecting_enginer��s�����

�
����C��I��#�E�����(��/�/�G�H��
�C��
)�
)�F��~�H�������
"�>�/�8�F�� �.�.�6�F���F�N��Mrc�j�ddlm}ddlm}|sd}n|�dd��}|pt
jj}||��}|�;t
j�|jt
jjjkr
t
j	}nai}n^t
j�R|jt
jjjkr3t
j	�
��}|�|��||fi|��}d|_t|jtj��rd|j_d|j_|r�t%j|jdt(j��t%j|jdt(j��t%j|jd	t(j��t(�|��|S)
zBProduce an engine configured by --options with optional overrides.r��
create_engine)�make_urlT�
use_reaperNr"r&r*)�
sqlalchemyr��sqlalchemy.engine.urlr��poprrKr��
drivername�db_opts�copy�update�_has_events�
isinstancer
�	QueuePool�_timeout�
_max_overflowr	�listenrXr"r&r*r)r�rEr�r�r��default_optrs       rr�r��s���)�(�(�(�(�(�.�.�.�.�.�.��5��
�
��[�[��t�4�4�
�

�
����C�
�(�3�-�-�C����9����&�)�-�2J� J� J��n�G�G��G�G�	��	�3�>�V�Y�]�5M�#M�#M��n�)�)�+�+�����7�#�#�#�
�]�3�
*�
*�'�
*�
*�F��F���&�+�t�~�.�.�&� ����$%���!��*�
��V�[�)�^�-C�D�D�D�
��V�[�*�n�.E�F�F�F�
��V�[�,��0I�J�J�J��!�!�&�)�)�)��Mrc�����ddlm}|stjj}g��fd�}�fd�}�fd�}||dzd|����t�d��rJ���_|�_|�_�S)	a'Provides a mocking engine based on the current testing.db.

    This is normally used to test DDL generation flow as emitted
    by an Engine.

    It should not be used in other cases, as assert_compile() and
    assert_sql_execution() are much better choices with fewer
    moving parts.

    rr�c�2����|��dSr)r�)�sql�are�buffers   �r�executorzmock_engine.<locals>.executor's����
�
�c�����rc�@��d��D��}||ks
J|���dS)Nc	�T�g|]%}tjddt|������&S)z[\n\t]r\)�re�sub�str)�.0�ss  r�
<listcomp>z3mock_engine.<locals>.assert_sql.<locals>.<listcomp>+s,��>�>�>�!���y�"�c�!�f�f�-�-�>�>�>rrT)�stmts�recvr�s  �r�
assert_sqlzmock_engine.<locals>.assert_sql*s-���>�>�v�>�>�>���u�}�}�}�d�}�}�}�}�}rc�`����j�d��fd��jD����S)N�
c3�^�K�|]'}t|�������V��(dS))rZN)r��compile)r�r�rvs  �r�	<genexpr>z1mock_engine.<locals>.print_sql.<locals>.<genexpr>0s9�����H�H�q��Q�Y�Y�q�Y�1�1�2�2�H�H�H�H�H�Hr)rZ�join�mock)rvrs@�r�	print_sqlzmock_engine.<locals>.print_sql.s4�����N���y�y�H�H�H�H�F�K�H�H�H�H�H�Hrz://r�)�strategyr�)	r�r�rrKrwrYr�r�r�)�dialect_namer�r�r�r�r�rs     @@r�mock_enginer�s�����)�(�(�(�(�(��&��y�~��
�F������#�#�#�#�#�I�I�I�I�I��]��u��v�����F��v�v�&�&�&�&�&��F�K�"�F�� �F���Mrc�8�eZdZdZd�Zd	d�Zd�Zd�Zd�Zd�Z	dS)
�DBAPIProxyCursorzuProxy a DBAPI cursor.

    Tests can provide subclasses of this to intercept
    DBAPI-level cursor operations.

    c�F�||_||_|j|i|��|_dSr)rr@r�)rrrBrdr�s     rrzDBAPIProxyCursor.__init__Ds,��������!�d�k�4�2�6�2�2����rNc�T�|r|jj||fi|��S|jj|fi|��Sr)r�r�)r�stmt�
parametersres    rr�zDBAPIProxyCursor.executeIsF���	3�&�4�;�&�t�Z�>�>�2�>�>�>�&�4�;�&�t�2�2�r�2�2�2rc�*�|jj||fi|��Sr)r��executemany)rr��paramsres    rr�zDBAPIProxyCursor.executemanyOs!��&�t�{�&�t�V�:�:�r�:�:�:rc�,�t|j|��Sr)rsr�r�s  rr�zDBAPIProxyCursor.__getattr__Rs���t�{�C�(�(�(rc��|SrrTrs r�	__enter__zDBAPIProxyCursor.__enter__Us���rc��dSrrT)rrds  r�__exit__zDBAPIProxyCursor.__exit__Xs���rr)
rQrRrS�__doc__rr�r�r�r�r�rTrrr�r�<s}��������3�3�3�
3�3�3�3�;�;�;�)�)�)����
�
�
�
�
rr�c�*�eZdZdZd�Zd�Zd�Zd�ZdS)�DBAPIProxyConnectionz}Proxy a DBAPI connection.

    Tests can provide subclasses of this to intercept
    DBAPI-level connection operations.

    c�l�|j���x|_|_||_||_dSr)r
�_creatorrB�_sqla_unwrapr�
cursor_cls)rrr�s   rrzDBAPIProxyConnection.__init__ds1��(.��(<�(<�(>�(>�>��	�D�%����$����rc�:�|j|j|jg|�Ri|��Sr)r�rrB)rrdr�s   rr�zDBAPIProxyConnection.cursoris*���t��t�{�D�I�G��G�G�G��G�G�Grc�8�|j���dSr)rBrNrs rrNzDBAPIProxyConnection.closels���	�������rc�,�t|j|��Sr)rsrBr�s  rr�z DBAPIProxyConnection.__getattr__os���t�y�#�&�&�&rN)rQrRrSr�rr�rNr�rTrrr�r�\s]��������%�%�%�
H�H�H����'�'�'�'�'rr�c�6�����fd�}td|i���S)zIProduce an engine that provides proxy hooks for
    common methods.

    c�0���tj���Sr)rrK)�conn_clsr�s��r�	mock_connz"proxying_engine.<locals>.mock_conn{s����x��	�:�.�.�.r�creator)rE)r�)r�r�r�s`` r�proxying_enginer�ss:����/�/�/�/�/�/��9�i�"8�9�9�9�9rr)NN)�
__future__rr�r.rr\rr�utilrr	r
�objectrrXrarfrirlrnryr{r�r�r�r�r�r�rTrr�<module>r�sD��'�&�&�&�&�&�	�	�	�	���������������������������������������Q�Q�Q�Q�Q�v�Q�Q�Q�h"�!�#�#�� � � ��+�+���+��&�&���&��������#�#���#�����+ �+ �+ �+ �+ �v�+ �+ �+ �\����(#�#�#�#�L%�%�%�%�P
�
�
�
�
�v�
�
�
�@'�'�'�'�'�6�'�'�'�0"�.>�:�:�:�:�:�:r

Hacked By AnonymousFox1.0, Coded By AnonymousFox