HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/cloudlinux/venv/lib/python3.11/site-packages/gitdb/test/__pycache__/lib.cpython-311.opt-1.pyc
�

�hw���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��|_|jsrtj	d|j��tj
j}tj
�|||t������d��|_dSdS)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__)�cls�ospd�	__class__s  ��C/opt/cloudlinux/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�O�O�		O�	Os� $�
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�r7r8s` 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)r5r�
src_pack_globr7s   �rr8zwith_packs_rw.<locals>.wrapper_s7���$�Y�/�/�
��=�$�T�B�B�B�B��t�D�$���r#r9r:s` r�
with_packs_rwrB[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�basenamerH�OSErrorr.�copy)�source_glob�
target_dirr>�src_file�targets     rr@r@ts����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)r4�data�odatas   r�make_objectrf�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_rbr)rZr[�ds   r�make_memory_fileri�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�r5s r�__init__zDummyStream.__init__�s����
���
�����r#c�"�d|_||_dS�NT)rmrn)r5�sizes  r�readzDummyStream.read�s����
���
�
�
r#c��d|_dSrs)rorps r�closezDummyStream.close�s
������r#c��dS�N�rps r�_assertzDummyStream._assert�����r#N)rrrrqrurwr{rzr#rrkrk�sP���������
����������r#rkc��eZdZd�Zd�ZdS)�
DeriveTestc�H�|�d��|_||_dS)N�myarg)�popr��args)r5�shar4rt�streamr��kwargss       rrqzDeriveTest.__init__�s ���Z�Z��(�(��
���	�	�	r#c��dSryrzrps rr{zDeriveTest._assert�r|r#N)rrrrqr{rzr#rr~r~�s2�������������r#r~)rC)F)r �gitdbrr1rWr�iorrI�unittestr)r.rr,r�	functoolsr�TestCaserr;rBr?r@r_rfrirkr~rzr#r�<module>r�s���
$�#�������
�
�
�
�
�
�
�
�������������������������
�
�
�
�	�	�	�	�	�	�	�	�����������
0�0�0�0�0�x� �0�0�0�F���<���$I�I�I�I�
.�
.�
.�
.�$
�
�
�
�(�(�(�������������$����������r#