Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/testing/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/testing/__pycache__/util.cpython-312.pyc
�

���g�8��L�ddlmZddlmZddlZddlZddlZddlmZddl	Z	ddl
Z
ddl
mZddlZddl
Z
ddlmZddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dlmZd
dl m!Z!d
dl m"Z"d
dl m#Z#d
dl m$Z$e#sd�Z%e%xZ&Z'nejPZ&d�Z'd�Z)d5d�Z*d�Z+Gd�de,�Z-d �Z.d!�Z/d"�Z0d#�Z1d$�Z2d%�Z3e!d&��Z4d'�Z5d(�Z6d)�Z7d6d*�Z8d+�Z9Gd,�d-e:�Z;d.�Z<			d7d0�Z=d1�Z>d2�Z?d3�Z@ej�d/d8d4��ZBy)9�)�annotations)�dequeN)�chain)�	getsizeof)�Any�)�config)�mock�)�inspect)�
Connection)�Column)�DropConstraint)�	DropTable)�ForeignKeyConstraint)�MetaData)�Table��schema)�Integer��	decorator)�defaultdict)�has_refcount_gc)�inspect_getfullargspecc�T�tj�tj�y�N)�gc�collect)�argss �H/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/testing/util.py�non_refcount_gc_collectr",s��
�
�
��
�
�
��c��yr�r%r#r!�lazy_gcr&5s��r#c#���K�t�}ddl}|j|�|D]4�td|jdz�D]��j
��fd�f����6y�w)Nr���rc�(���j|��Sr)�dumps)�d�pickle_�protocols ��r!�<lambda>zpicklers.<locals>.<lambda>Bs���7�=�=��H�+Er#)�set�pickle�add�range�HIGHEST_PROTOCOL�loads)�picklersr0r,r-s  @@r!r5r59sU������u�H���L�L������b�&�"9�"9�A�"=�>�H��-�-�!E�E�E�?��s�AAc�0�tj||��S)N)�k)�random�choices)�
populationr7s  r!�random_choicesr;Es���>�>�*��*�*r#c���t|t�rt||�S|tjdd|zz�zjtj�td|�zS)N�1�0�
)�
isinstance�float�round�decimal�Decimal�to_integral�ROUND_FLOOR�pow)�value�precs  r!�
round_decimalrJIs\���%����U�D�!�!�
�G�O�O�C�#��*�$4�5�5�B�B������B��
��r#c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�	RandomSetc�~�ttj|��}tj|�t|�Sr)�listr/�__iter__r8�shuffle�iter)�self�ls  r!rOzRandomSet.__iter__Ts*������d�#�$�����q���A�w�r#c��tjdt|�dz
�}ttj|��|}|j
|�|S)Nrr)r8�randint�lenrNr/rO�remove)rR�index�items   r!�popz
RandomSet.popYsC�����q�#�d�)�a�-�0���C�L�L��&�'��.�����D���r#c�@�ttj||��Sr)rLr/�union�rR�others  r!r\zRandomSet.union_s������4��/�0�0r#c�@�ttj||��Sr)rLr/�
differencer]s  r!r`zRandomSet.differencebs�������e�4�5�5r#c�@�ttj||��Sr)rLr/�intersectionr]s  r!rbzRandomSet.intersectiones����)�)�$��6�7�7r#c��t|�Sr)rL)rRs r!�copyzRandomSet.copyhs�����r#N)	�__name__�
__module__�__qualname__rOrZr\r`rbrdr%r#r!rLrLSs ���
�1�6�8�r#rLc��tt�}|D]\}}||j|��t|�D]\}}||dD]}|||vs�y�y)zATrue if the given sorting conforms to the given partial ordering.NFT)rr/r1�	enumerate)�tuples�sorted_elements�deps�parent�child�i�node�ns        r!�conforms_partial_orderingrrlse���s��D��
����V������ ��_�-���4� ���$�A��t�A�w���%�.�
r#c����tt��|D]\}}�|j|����fd��t�|��S)Nc3���K�t|�dk(rt|���y|D]G}t|�j|g�}|j	�|�r�3�|�D]
}|g|z����Iy�w)Nr)rVrNr/r`rb)�elements�elem�subset�sub_ordering�_all_orderings�edgess    ��r!ryz-all_partial_orderings.<locals>._all_orderingssk������x�=�A���x�.� � ���X��1�1�4�&�9���*�*�5��;�7�(6�v�(>��#�f�|�3�3�)?�!�s�AA-�A-)rr/r1rQ)rjrurmrnryrzs    @@r!�all_partial_orderingsr{zsD������E��
���
�e����� � �4���x�(�)�)r#c��	||_|S#t$rEtj|j|j
||j|j�}Y|SwxYw)acReturn a function with a given __name__.

    Will assign to __name__ and return the original function if possible on
    the Python implementation, otherwise a new function will be constructed.

    This function should be phased out as much as possible
    in favor of @decorator.   Tests that "generate" many named tests
    should be modernized.

    )re�	TypeError�types�FunctionType�__code__�__globals__�__defaults__�__closure__)�fn�names  r!�function_namedr��sX��
����
�I��	�
�
�
�
��K�K�����r������
���I�	
�s��A
A�Ac���|j�}	||g|��i|��}|jddd�|S#tj�}|j|�}|s�|cYSxYw)aRun the given function under the given contextmanager,
    simulating the behavior of 'with' to support older
    Python versions.

    This is not necessary anymore as we have placed 2.6
    as minimum Python version, however some tests are still using
    this structure.

    N)�	__enter__�__exit__�sys�exc_info)�ctxr��arg�kw�obj�resultr��raise_s        r!�run_as_contextmanagerr��sj���-�-�/�C�
��C�$�#�$��$�����T�4��&��
����<�<�>������x�(�����M�s	� 3�*Ac�>�|D�chc]
}t|���c}Scc}w)z�Converts the results of sql execution into a plain set of column tuples.

    Useful for asserting the results of an unordered query.
    ��tuple)�results�rows  r!�rowsetr��s ��#*�*�'�3�E�#�J�'�*�*��*s�c��J|��rr%)�msgs r!�failr��s���#��5r#c�p�ddlm}tj�}|d}t	|dd�}||_	||i|��|j
�|jj}|r2t||�|j�j�||_St|tj�||_S#|j
�|jj}|r2t||�|j�j�||_wt|tj�||_wxYw)ztProvide bound MetaData for a single test, dropping afterwards.

    Legacy; use the "metadata" pytest fixture.

    r)�fixturesr�metadataN)�r�rr�getattrr��close_all_sessions�base�_connection_fixture_connection�drop_all_tables_from_metadata�get_transaction�commitr	�db)r�r r�r�r�rR�	prev_meta�cfcs        r!�provide_metadatar��s
������ �H���7�D���j�$�/�I��D�M�"��4��2��	�#�#�%��m�m�:�:���
*�(�C�8�

���!�(�(�*�"��
�
*�(�F�I�I�>�!��
��#	�#�#�%��m�m�:�:���
*�(�C�8�

���!�(�(�*�"��
�
*�(�F�I�I�>�!��
�s�B8�8A=D5c
�J��t�}|D]�|j���t|�}tj|D��cgc]2�dj�fd�|D��ft
�fd�|D��z��4c}ddt|�zzdj|�d��Scc}w)aqA facade around @testing.combinations() oriented towards boolean
    keyword-based arguments.

    Basically generates a nice looking identifier based on the keywords
    and also sets up the argument names.

    E.g.::

        @testing.flag_combinations(
            dict(lazy=False, passive=False),
            dict(lazy=True, passive=False),
            dict(lazy=False, passive=True),
            dict(lazy=False, passive=True, raiseload=True),
        )
        def test_fn(lazy, passive, raiseload): ...

    would result in::

        @testing.combinations(
            ("", False, False, False),
            ("lazy", True, False, False),
            ("lazy_passive", True, True, False),
            ("lazy_passive", True, True, True),
            id_="iaaa",
            argnames="lazy,passive,raiseload",
        )
        def test_fn(lazy, passive, raiseload): ...

    �_c3�H�K�|]}�j|d�s�|���y�w�FN��get��.0r7r+s  �r!�	<genexpr>z$flag_combinations.<locals>.<genexpr>s�����9��A����q�%��a��s�"�"c3�B�K�|]}�j|d����y�wr�r�r�s  �r!r�z$flag_combinations.<locals>.<genexpr>s�����2�T��A�E�E�!�U�O�T�s�ro�a�,)�id_�argnames)r/�update�sortedr	�combinations�joinr�rV)r��keysr+s  `r!�flag_combinationsr��s����>�5�D�
�����A����$�<�D����"�

�"���X�X�9��9�
9�;��2�T�2�2�
3�!�

�

�3��T��?�#����$�����

s�7B c���t��}�|dD�cgc]}tj���c}�}�fd�}tjtt
|��D�cgc]}||�f��
c}i|��Scc}wcc}w)Nrc�*�����fd�}d�z|_|S)Nc����di|���S)Nr%r%)r��lambda_arg_sets�poss ��r!�fixturez<lambda_combinations.<locals>.create_fixture.<locals>.fixture)s���"�(�R�(��-�-r#z
fixture_%3.3d)re)r�r�r�s` �r!�create_fixturez+lambda_combinations.<locals>.create_fixture(s���	.�+�S�0����r#)rr
�Mockr	r�r2rV)r�r�r r��arg_setsr�ros`      r!�lambda_combinationsr�#s����!�/�2�D���Q�� @�������� @�A�H�����(-�c�(�m�(<�	=�(<�1�>�!��
�(<�	=��AC����!A��
>s�A6�A;c��t|�d}|D�cic]}||j|���}}t|j�}|j	|�tj|j|�}|di|��Scc}w)z�Given a no-arg lambda and a namespace, return a new lambda that
    has all the values filled in.

    This is used so that we can have module-level fixtures that
    refer to instance-level variables using lambdas.

    rr%)rrZ�dictr�r�r~rr�)�__fnr��pos_argsr��
pass_pos_args�glb�new_fns       r!�resolve_lambdar�4sx��&�d�+�A�.�H�19�:��#�S�"�&�&��+�%��M�:�
�t���
 �C��J�J�r�N�
�
�
��
�
�s�
3�F��"�M�"�"��	;s�A<c����fd�}|S)z&Provide MetaData for a pytest fixture.c�H����fd�}tj���|�S)Nc3�$�K�tj�x}|_	�||�}|jtj
�|��|j
tj
�y#|j
tj
�wxYw�wr)rrr��
create_allr	r��drop_all)rRr�r�r�s   �r!�run_ddlz3metadata_fixture.<locals>.decorate.<locals>.run_ddlIsh�����'-���'8�8�H�t�}�
-��D�(�+���#�#�F�I�I�.����!�!�&�)�)�,���!�!�&�)�)�,�s�B�,A,� B�,!B
�
B)�scope)r	r�)r�r��ddls` �r!�decoratez"metadata_fixture.<locals>.decorateHs ���		-�)�v�~�~�C�(��1�1r#r%)r�r�s` r!�metadata_fixturer�Es���2��Or#c�$��t�fd��}|S)ziForce the given table names to be dropped after test complete,
    isolating for foreign key cycles

    c����	||i|��ttjttj����S#ttjttj����wxYw)N)�
include_names)�drop_all_tablesr	r�r)r�r r��namess   �r!�gozforce_drop_names.<locals>.go_sG���	P��t�?�r�?��F�I�I�w�v�y�y�'9��O��O�F�I�I�w�v�y�y�'9��O�s	�>�5A3r)r�r�s` r!�force_drop_namesr�Ys ����P��P��Ir#c� �eZdZdZd�Zd�ZeZy)�adictz,Dict keys available as attributes.  Shadows.c�X�	||S#t$rtj||�cYSwxYwr)�KeyErrorr��__getattribute__)rR�keys  r!r�zadict.__getattribute__ls3��	4���9����	4��(�(��s�3�3�	4�s��)�)c�D�t|D�cgc]}||��	c}�Scc}wrr�)rRr�r�s   r!�__call__zadict.__call__rs#���4�0�4�C�d�3�i�4�0�1�1��0s�N)rerfrg�__doc__r�r��get_allr%r#r!r�r�is��6�4�2��Gr#r�c����ddlm���fd�}t|t�s"|j	�5}||�ddd�y||�y#1swYyxYw)Nr)�enginesc�
���jj|�|jjs4ddlm}|j
dd��5�j|�ddd�y�j|�y#1swYyxYw)Nr)�
assertionszCan't sort tablesF)�assert_)�testing_reaper�prepare_for_drop_tables�dialect�supports_alterr�r��expect_warningsr�)�
connectionr�r�r�s  ��r!r�z)drop_all_tables_from_metadata.<locals>.go{sv������6�6�z�B��!�!�0�0�$��+�+�#�U�,���!�!�*�-���

���j�)���s�A9�9B)r�r�r@r
�begin)r��engine_or_connectionr�r�r�s`   @r!r�r�xsI����*��*�J�7�
!�
'�
'�
)�Z��z�N�*�
)�	�� �*�
)�s�	A
�
Arc���|�t|�}|�|dk(sJd��|f}|j�5}t|j|���D]�\}}|r?|�|d|vr�|j	tt
|dt�|d�����G|s�J|jjs�a|D]�\}}	|�|d|vr�t
|dt�tdt�tdt�|d��}
|j	tt|
jjg|
jj g|	�	�������	ddd�y#1swYyxYw)
Nrz2consider_schemas and schema are mutually exclusive)�consider_schemasrrr�x�y)r�)r/r��reversed�%sort_tables_on_foreign_key_dependency�executerrrr�r�rrrr�cr�r�)�engine�	inspectorrr�r��conn�	table_key�fkcs�t_key�fkc�tbs           r!r�r��sf��� ��M�*�
�
���$
�
�	@�?�	@�
�#�9��	����4�'��;�;�!1�
<�
� 
�O�I�t�
�!�-�!�!��M�9�������i��l�H�J�y��|�L���
��~�~�4�4��"&�J�E�3�%�1�!�!�H�M�9� ���a�� �
��s�G�,��s�G�,�$�Q�x��B��L�L�&�0�"�$�$�&�&��B�D�D�F�F�8�#�N���#'�' 
�
���s�A%E�B8E�E c�$��t�fd��}|S)Nc�`��	||i|���j�S#�j�wxYwr)�_clear)r�r�r��	event_clss   �r!r�z!teardown_events.<locals>.decorate�s,���	��s�>�b�>������I����s��-r)rr�s` r!�teardown_eventsr
�s��������Or#c�������d�}ttttttt|t
ttti�t��td������fd���|�S)z�Returns the approximate memory footprint an object and all of its
    contents.

    source: https://code.activestate.com/recipes/577504/


    c�H�tj|j��Sr)r�
from_iterable�items)r+s r!�dict_handlerz total_size.<locals>.dict_handler�s���"�"�1�7�7�9�-�-r#rc
���t|��vry�jt|��t|��}�j�D]2\}}t	||�s�|tt
�||���z
}|S|S)Nr)�idr1rrr@�sum�map)�o�s�typ�handler�all_handlers�default_size�seen�sizeofs    ����r!rztotal_size.<locals>.sizeof�sv���
�a�5�D�=������A����a��&��(�.�.�0�L�C���!�S�!��S��V�W�Q�Z�0�1�1�����	1��r#)r�rQrNrr�r/�	frozensetr)rrrrrrs  @@@@r!�
total_sizer �sR���.�	�t��d�
�t��l��T��4�
�L��5�D��Q�<�L�
��!�9�r#c��|g}t�}d}|rB|jd�}||ur|dz
}n$t|t�r|rt	|�|gz|z}|r�B|S)z�given a cache key tuple, counts how many instances of actual
    tuples are found.

    used to alert large jumps in cache key complexity.

    rr)�objectrZr@r�rN)�tup�stack�sentinel�num_elementsrvs     r!�count_cache_key_tuplesr'�sh���E�E��x�H��L�
��y�y��|���8���A��L�
��e�
$���T�
�h�Z�/�%�7��
��r#c	#�K�tj�}d��tj�|z
}||kDr&	|�tjd|d�d|�d��yy#tjd|d�d|�d��wxYw�w)Nztest took too long (z.4fz seconds > �))�timer	�	skip_test)�seconds�cleanup�now�secs    r!�skip_if_timeoutr0s������)�)�+�C�	�
�)�)�+��
�C�
�W�}�	��I����&�s�3�i�{�7�)�1�E�
�	��
���&�s�3�i�{�7�)�1�E�
�s�5B�A�B�A=�=B)r)�function)NrN)r,rAr-r)C�
__future__r�collectionsr�
contextlibrCr�	itertoolsrr8r�rr*r~�typingrr�r	r
rrr
rrrrrrr�sql�sql.sqltypesr�utilrrrrr"�
gc_collectr&rr5r;rJr/rLrrr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r r'�contextmanagerr0r%r#r!�<module>r<s6��#����	��
�
����������#��)����"���"�)���3�2�J�����J�
�	F�+�����2�*�$�(�2+���("��("�V.�b�"#�"�(
� �D��!�4���5�p�#�L�,�����r#

ZeroDay Forums Mini