AlkantarClanX12

Your IP : 52.14.160.64


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

�

�܋fw���dZddlmZddlZddlZddlmZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZGd�de	j��Zd	�Zd
�Zdd�Zdd�Zdd�Zd�Zdd�ZGd�d��ZGd�de��ZdS)zUtilities used in ODB testing�)�OStreamN)�array)�BytesIO)�wrapsc�6��eZdZdZdZe�fd���Z�xZS)�TestBasez�Base class for all tests

    TestCase providing access to readonly repositories using the following member variables.

    * gitrepopath

     * read-only base path of the git source repository, i.e. .../git/.git
    �GITDB_TEST_GIT_REPO_BASEc	����	t�����n#t$rYnwxYwtj�|j��|_|jsptj	d|j��tj
j}tj
�|||t������d��|_|j�d��sJ�dS)NzpYou can set the %s environment variable to a .git repository of your choice - defaulting to the gitdb repositoryz.git)�super�
setUpClass�AttributeError�os�environ�get�k_env_git_repo�gitrepopath�logging�info�path�dirname�join�__file__�endswith)�cls�ospd�	__class__s  ��_/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/gitdb/test/lib.pyrzTestBase.setUpClass(s����	��G�G��� � � � ���	�	�	��D�	�����*�.�.��);�<�<�����	O��L�C�EH�EW�
X�
X�
X��7�?�D� �g�l�l�4�4���T�T�(�^�^�0D�0D�+E�+E�v�N�N�C�O���'�'��/�/�/�/�/�/�/s� $�
1�1)�__name__�
__module__�__qualname__�__doc__r�classmethodr�
__classcell__)rs@rrrsU���������0�N��
0�
0�
0�
0��[�
0�
0�
0�
0�
0�rc�*���fd�}�j|_|S)z�Create a temporary directory which can be written to, remove it if the
    test succeeds, but leave it otherwise to aid additional debuggingc
����tj�j���}tj|��d}		�||��|s(tj��tj|��SS#t$rDtj�dt|��j�d�j�d|�d���d}�wxYw#|s(tj��tj|��wwxYw)N)�prefixFzTest �.z failed, output is at �
T)�tempfile�mktemprr�mkdir�gc�collect�shutil�rmtree�	Exception�sys�stderr�write�type)�selfr�keep�funcs   �r�wrapperz"with_rw_directory.<locals>.wrapperAs�����d�m�4�4�4��
��������	$�
��t�D�$�'�'��
$��
�����
�d�#�#�#�#�
$���
�
�
��
� � �!n��d���)<�!n�!n�t�}�!n�!n�dh�!n�!n�!n�o�o�o����
������
$��
�����
�d�#�#�#�#�
$���s�A*�*AB8�8B;�;,C'�r�r8r9s` r�with_rw_directoryr<=s-���$�$�$�$�$�,�}�G���Nr$c�*���fd�}�j|_|S)z�Function that provides a path into which the packs for testing should be
    copied. Will pass on the path to the actual function afterwardsc�^��td��}t||d����||��S)Nzpacks/*T)�hard_link_ok)�fixture_path�copy_files_globbed)r6r�
src_pack_globr8s   �rr9zwith_packs_rw.<locals>.wrapper_s7���$�Y�/�/�
��=�$�T�B�B�B�B��t�D�$���r$r:r;s` r�
with_packs_rwrC[s-��� � � � � ��}�G���Nr$�c��tj�tj�t��d|��S)z�:return: absolute path into the fixture directory
    :param relapath: relative path into the fixtures directory, or ''
        to obtain the fixture directory itself�fixtures)rrrrr)�relapaths rr@r@ms*���7�<�<������1�1�:�x�H�H�Hr$Fc�~�tj|��D]�}|r�ttd��rytj�|tj�|����}	tj||���m#t$rtj	||��Y��wxYwtj	||����dS)z�Copy all files found according to the given source glob into the target directory
    :param hard_link_ok: if True, hard links will be created if possible. Otherwise
        the files will be copied�linkN)
�glob�hasattrrrr�basenamerI�OSErrorr/�copy)�source_glob�
target_dirr?�src_file�targets     rrArAts����I�k�*�*�	.�	.���	.�G�B��/�/�	.��W�\�\�*�b�g�.>�.>�x�.H�.H�I�I�F�
2����&�)�)�)�)���
2�
2�
2���H�j�1�1�1�1�1�
2����
�K��*�-�-�-�-�	.�	.s�,B�B$�#B$c��|dz}t|��}|r#t|��}tj|��t	d|��}|���S)zb:return: string with given size in bytes
    :param randomize: try to produce a very random stream��i)�range�list�random�shuffler�tobytes)�
size_in_bytes�	randomize�actual_size�producer�as     r�
make_bytesr`�s[�� �1�$�K��[�!�!�H��!���>�>����x� � � �
�c�8���A��9�9�;�;�r$c�V�dt|��z}|�d��|zS)z0:return: bytes resembling an uncompressed objectzblob %i�ascii)�len�encode)r5�data�odatas   r�make_objectrg�s)���#�d�)�)�#�E��<�<�� � �4�'�'r$c�^�t||��}t|��t|��fS)z`:return: tuple(size_of_stream, stream)
    :param randomize: try to produce a very random stream)r`rcr)r[r\�ds   r�make_memory_filerj�s*��	�=�)�,�,�A��q�6�6�7�1�:�:��r$c�&�eZdZd�Zd�Zd�Zd�ZdS)�DummyStreamc�0�d|_d|_d|_dS)NFr)�was_read�bytes�closed�r6s r�__init__zDummyStream.__init__�s����
���
�����r$c�"�d|_||_dS�NT)rnro)r6�sizes  r�readzDummyStream.read�s����
���
�
�
r$c��d|_dSrt)rprqs r�closezDummyStream.close�s
������r$c��|jsJ�dS�N)rnrqs r�_assertzDummyStream._assert�s���}���}��r$N)rrr rrrvrxr{�r$rrlrl�sP���������
����������r$rlc��eZdZd�Zd�ZdS)�
DeriveTestc�H�|�d��|_||_dS)N�myarg)�popr��args)r6�shar5ru�streamr��kwargss       rrrzDeriveTest.__init__�s ���Z�Z��(�(��
���	�	�	r$c�*�|jsJ�|jsJ�dSrz)r�r�rqs rr{zDeriveTest._assert�s"���y���y��z���z��r$N)rrr rrr{r|r$rr~r~�s2�������������r$r~)rD)F)r!�gitdbrr2rXr�iorrJ�unittestr*r/rr-r�	functoolsr�TestCaserr<rCr@rAr`rgrjrlr~r|r$r�<module>r�s���
$�#�������
�
�
�
�
�
�
�
�������������������������
�
�
�
�	�	�	�	�	�	�	�	�����������
0�0�0�0�0�x� �0�0�0�F���<���$I�I�I�I�
.�
.�
.�
.�$
�
�
�
�(�(�(�������������$����������r$