Submit
Path:
~
/
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
gitdb
/
test
/
__pycache__
/
File Content:
lib.cpython-311.opt-1.pyc
� � hw � � � d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlZddl Z ddl Z ddlZddlZddl Z ddlZddlmZ G d� de j � � Zd � Zd � Zdd�Zdd�Zdd�Zd� Zdd�Z G d� d� � Z G d� de� � ZdS )zUtilities used in ODB testing� )�OStreamN)�array)�BytesIO)�wrapsc �6 � � e Zd ZdZdZe� 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 $ r Y nw xY wt j � | j � � | _ | j srt j d| j � � t j j }t j � | | |t � � � � � � d� � | _ d S d S )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__)r s @r r r sU �� � � � � �� � 0�N� � 0� 0� 0� 0� �[� 0� 0� 0� 0� 0� r c �* � � � 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 �� �� t j �j �� � }t j |� � d} �| |� � |s(t j � � t j |� � S S # t $ rD t j � dt | � � j � d�j � d|�d�� � d}� w xY w# |s(t j � � t j |� � w w xY w)N)�prefixFzTest �.z failed, output is at � T)�tempfile�mktempr r �mkdir�gc�collect�shutil�rmtree� Exception�sys�stderr�write�type)�selfr �keep�funcs �r �wrapperz"with_rw_directory.<locals>.wrapperA s �� ���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 �r7 r8 s ` 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 �^ �� t d� � }t ||d�� � �| |� � S )Nzpacks/*T)�hard_link_ok)�fixture_path�copy_files_globbed)r5 r � src_pack_globr7 s �r r8 zwith_packs_rw.<locals>.wrapper_ s7 �� �$�Y�/�/� ��=�$�T�B�B�B�B��t�D�$���r# r9 r: s ` r � with_packs_rwrB [ s- �� � � � � � � �}�G���Nr# � c � � t j � t j � 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)r r r r r )�relapaths r r? r? m s* � � �7�<�<������1�1�:�x�H�H�Hr# Fc �~ � t j | � � D ]�}|r�t t d� � ryt j � |t j � |� � � � } t j ||� � �m# t $ r t j ||� � Y ��w xY wt j ||� � ��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�hasattrr r r �basenamerH �OSErrorr. �copy)�source_glob� target_dirr>