
    chq                        S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKJr   " S S\	R"                  5      rS	 rS
 rSS jrSS jrSS jrS rSS jr " S S5      r " S S\5      rg)zUtilities used in ODB testing    )OStreamN)array)BytesIO)wrapsc                   :   ^  \ rS rSrSrSr\U 4S j5       rSrU =r	$ )TestBase   zBase 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U ]  5         [        R                  R                  U R                  5      U l        U R                  (       dv  [        R                  " SU R                  5        [        R                  R                  n[        R                  R                  U" U" U" [        5      5      5      S5      U l        U R                  R                  S5      (       d   eg ! [         a     Nf = f)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     aC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\gitdb/test/lib.pyr   TestBase.setUpClass(   s    	G  **..););<LL C  EH  EW  EWX77??D ggll4T(^0D+EvNCO''////  		s   C) )
C65C6 )
__name__
__module____qualname____firstlineno____doc__r   classmethodr   __static_attributes____classcell__)r   s   @r   r   r      s#     0N 0 0    r   c                 6   ^  U 4S jnT R                   Ul         U$ )zCreate a temporary directory which can be written to, remove it if the
test succeeds, but leave it otherwise to aid additional debuggingc           
      
  > [         R                  " TR                  S9n[        R                  " U5        Sn  T" X5      U(       d,  [
        R                  " 5         [        R                  " U5        $ $ ! [         aK    [        R                  R                  S[        U 5      R                   STR                   SU< S35        Sne f = f! U(       d,  [
        R                  " 5         [        R                  " U5        f f = f)N)prefixFzTest .z failed, output is at 
T)tempfilemktempr!   r   mkdirgccollectshutilrmtree	Exceptionsysstderrwritetype)selfr   keepfuncs      r   wrapper"with_rw_directory.<locals>.wrapperA   s    dmm4
	$D' 

d#   

  5d)<)<(=Qt}}oMcdhckkm!no 

d# s   A5 5AC

C 5Dr!   r=   r>   s   ` r   with_rw_directoryrB   =   s    $, }}GNr)   c                 6   ^  U 4S jnT R                   Ul         U$ )zFunction that provides a path into which the packs for testing should be
copied. Will pass on the path to the actual function afterwardsc                 >   > [        S5      n[        X!SS9  T" X5      $ )Nzpacks/*T)hard_link_ok)fixture_pathcopy_files_globbed)r;   r   src_pack_globr=   s      r   r>   with_packs_rw.<locals>.wrapper_   s"    $Y/=TBDr)   r@   rA   s   ` r   with_packs_rwrJ   [   s      }}GNr)   c                     [         R                  R                  [         R                  R                  [        5      SU 5      $ )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   rF   rF   m   s(     77<<1:xHHr)   c                    [         R                   " U 5       H  nU(       ak  [        [        S5      (       aV  [        R                  R	                  U[        R                  R                  U5      5      n [        R                  " X45        Mu  [        R                  " X15        M     g! [         a    [        R                  " X15         M  f = f)zCopy 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   basenamerO   OSErrorr4   copy)source_glob
target_dirrE   src_filetargets        r   rG   rG   t   s     IIk*GB//WW\\*bgg.>.>x.HIF2)
 KK- +
  2H12s   4B'' C
Cc                     U S-  n[        U5      nU(       a!  [        U5      n[        R                  " U5        [	        SU5      nUR                  5       $ )z^: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_bytesrf      sH      1$K[!H>x c8A99;r)   c                 F    S[        U5      -  nUR                  S5      U-   $ )z0:return: bytes resembling an uncompressed objectzblob %i ascii)lenencode)r:   dataodatas      r   make_objectrm      s$    #d)#E<< 4''r)   c                 D    [        X5      n[        U5      [        U5      4$ )z\:return: tuple(size_of_stream, stream)
:param randomize: try to produce a very random stream)rf   ri   r   )ra   rb   ds      r   make_memory_filerp      s!     	=,Aq671:r)   c                   ,    \ rS rSrS rS rS rS rSrg)DummyStream   c                 .    SU l         SU l        SU l        g )NFr   )was_readbytesclosedr;   s    r   __init__DummyStream.__init__   s    
r)   c                     SU l         Xl        g NT)ru   rv   )r;   sizes     r   readDummyStream.read   s    
r)   c                     SU l         g r|   )rw   rx   s    r   closeDummyStream.close   s	    r)   c                 *    U R                   (       d   eg N)ru   rx   s    r   _assertDummyStream._assert   s    }}}r)   )rv   rw   ru   N)	r!   r"   r#   r$   ry   r~   r   r   r'   r    r)   r   rr   rr      s    
r)   rr   c                        \ rS rSrS rS rSrg)
DeriveTest   c                 <    UR                  S5      U l        XPl        g )Nmyarg)popr   args)r;   shar:   r}   streamr   kwargss          r   ry   DeriveTest.__init__   s    ZZ(
	r)   c                 P    U R                   (       d   eU R                  (       d   eg r   r   r   rx   s    r   r   DeriveTest._assert   s    yyyzzzr)   r   N)r!   r"   r#   r$   ry   r   r'   r    r)   r   r   r      s    r)   r   ) )F)r%   gitdbr   r7   r^   r   ior   rP   unittestr/   r4   r   r2   r   	functoolsr   TestCaser   rB   rJ   rF   rG   rf   rm   rp   rr   r   r    r)   r   <module>r      s~   
 $  
        	 	  
0x   0F<$I.$
( $ r)   