
    )Vh*                         d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
mZmZ ddlZddlZddlmZ dZd	 Z G d
 d      Z G d d      Zy)zTests for distutils.filelist.    N)debugfilelist)DistutilsTemplateError)FileList
glob_to_retranslate_pattern   )py39zinclude ok
include xo
exclude xo
include foo.tmp
include buildout.cfg
global-include *.x
global-include *.txt
global-exclude *.tmp
recursive-include f *.oo
recursive-exclude global *.x
graft dir
prune dir3
c                 B    | j                  dt        j                        S )z"Converts '/' in a string to os.sep/)replaceossep)ss    Y/home/dcms/DCMS/lib/python3.12/site-packages/setuptools/_distutils/tests/test_filelist.pymake_local_pathr      s    99S"&&!!    c                   N    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)TestFileListc                     |j                   D cg c]"  }|j                  t        j                  k(  s!|$ }}|rJ |j	                          y c c}w NrecordslevelnologgingWARNINGclearselfcaplogrecwarningss       r   assertNoWarningszTestFileList.assertNoWarnings%   s?    #)>>TCS[[GOO5SCTT| U
   "AAc                     |j                   D cg c]"  }|j                  t        j                  k(  s!|$ }}|sJ |j	                          y c c}w r   r   r   s       r   assertWarningszTestFileList.assertWarnings*   s>    #)>>TCS[[GOO5SCTTx Ur$   c                     t         j                  }t         j                  dk(  r#t        j                  t         j                        }dD ]  \  }}|d|iz  }t	        |      |k(  rJ  y )N\))zfoo*z(?s:foo[^%(sep)s]*)\Z)zfoo?z(?s:foo[^%(sep)s])\Z)zfoo??z(?s:foo[^%(sep)s][^%(sep)s])\Z)zfoo\\*z(?s:foo\\\\[^%(sep)s]*)\Z)zfoo\\\*z(?s:foo\\\\\\[^%(sep)s]*)\Z)zfoo????z2(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z)zfoo\\??z"(?s:foo\\\\[^%(sep)s][^%(sep)s])\Zr   )r   r   reescaper   )r   r   globregexs       r   test_glob_to_rezTestFileList.test_glob_to_re/   s`    ff66T>))BFF#C

 	-KD% UCL(Ed#u,,,	-r   c                    t               }t        }ddddd |d       |d       |d       |d	       |d
       |d       |d       |d       |d       |d      g|_        t        j	                  d      D ]'  }|j                         dk(  r|j                  |       ) ddd |d       |d       |d       |d       |d       |d      g	}|j                  |k(  sJ y )Nzfoo.tmpokxozfour.txtzbuildout.cfgz.hg/last-message.txtzglobal/one.txtzglobal/two.txtzglobal/files.xzglobal/here.tmpzf/o/f.oozdir/graft-onezdir/dir2/graft2zdir3/okzdir3/sub/ok.txt
 )r   r   allfilesMANIFEST_INsplitstripprocess_template_linefiles)r   	file_listmlplinewanteds        r   test_process_template_linez'TestFileList.test_process_template_lineB   s   J	  &' ! ! !!"
O !"	N!"#
	(  %%d+ 	2Dzz|r!++D1	2 &' ! !
O !"

 &(((r   c                    t               }|j                  d       |j                         j                  dk(  sJ |j	                  t
        dd       |j                  d       |j                         j                  dk(  sJ y )Nxxxr2   DEBUGTzxxx
)r   debug_print
readouterroutsetattrr   )r   capsysmonkeypatchr9   s       r   test_debug_printzTestFileList.test_debug_printo   sq    J	e$  "&&",,,E7D1e$  "&&'111r   c                 d    t               }g d}|j                  |       |j                  |k(  sJ y )N)abc)r   set_allfilesr3   )r   r9   r8   s      r   test_set_allfileszTestFileList.test_set_allfilesx   s0    J	u%!!U***r   c                     t               }g d|_        |j                          |j                          |j                  g dk(  sJ y )N)rI   rJ   rI   grK   rO   )rI   rJ   rK   rO   )r   r8   sortremove_duplicatesr   r9   s     r   test_remove_duplicatesz#TestFileList.test_remove_duplicates~   s9    J	8	##%"6666r   c                     t        t        ddd      d      sJ t        j                  d      }t        |dd      |k(  sJ t        t        ddd      d      sJ t        ddd      j	                  d      sJ y )NrI   TF)anchoris_regexsearch*.pyzfilelist.py)hasattrr   r)   compilerW   )r   r,   s     r   test_translate_patternz#TestFileList.test_translate_pattern   s    (TEJHUUU 

3 tdCuLLL (TDI8TTT !uELL
 	
 
r   c                     t               }|j                  d      rJ t               }ddg|_        |j                  d      sJ t               }ddg|_        |j                  d       |j                  dgk(  sJ y )NrX   a.pyzb.pyza.txt)r   exclude_patternr8   rR   s     r   test_exclude_patternz!TestFileList.test_exclude_pattern   s}    J	,,V444 J	!6*	((000 J	!7+	!!&)7)+++r   c                 ^   t               }|j                  g        |j                  d      rJ t               }|j                  ddg       |j                  d      sJ t               }|j                  J |j                  ddg       |j                  d       |j                  ddgk(  sJ y )NrX   r]   b.txt*)r   rL   include_patternr3   rR   s     r   test_include_patternz!TestFileList.test_include_pattern   s    J	r",,V444 J	01((000 J	!!)))01!!#&!!fg%6666r   c                 b
   t         }t               }dD ]5  }t        j                  t              5  |j                  |       d d d        7 t               }|j                  dd |d      g       |j                  d       |j                  dgk(  sJ | j                  |       |j                  d       |j                  dgk(  sJ | j                  |       t               }dd |d      g|_        |j                  d       |j                  d |d      gk(  sJ | j                  |       |j                  d       |j                  d |d      gk(  sJ | j                  |       t               }|j                  dd |d      g       |j                  d	       |j                  d |d      gk(  sJ | j                  |       |j                  d
       |j                  d |d      gk(  sJ | j                  |       t               }dd |d      g|_        |j                  d       |j                  dgk(  sJ | j                  |       |j                  d       |j                  dgk(  sJ | j                  |       t               }|j                  d |d       |d       |d      g       |j                  d       |j                   |d       |d      gk(  sJ | j                  |       |j                  d       |j                   |d       |d      gk(  sJ | j                  |       t               }d |d       |d       |d      g|_        |j                  d       |j                  d |d      gk(  sJ | j                  |       |j                  d       |j                  d |d      gk(  sJ | j                  |       t               }|j                  d |d       |d       |d      g       |j                  d       |j                   |d       |d      gk(  sJ | j                  |       |j                  d       |j                   |d       |d      gk(  sJ | j                  |       t               }d |d       |d       |d      g|_        |j                  d       |j                  d |d      gk(  sJ | j                  |       |j                  d       |j                  d |d      gk(  sJ | j                  |       y # 1 sw Y   xY w)N)	includeexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludegraftpruneblargr]   ra   zd/c.pyzinclude *.pyzinclude *.rbzexclude *.pyzexclude *.rbzglobal-include *.pyzglobal-include *.rbzglobal-exclude *.pyzglobal-exclude *.rbzd/b.pyzd/c.txtzd/d/e.pyzrecursive-include d *.pyzrecursive-include e *.pyzrecursive-exclude d *.pyzrecursive-exclude e *.pyzf/f.pyzgraft dzgraft ezprune dzprune e)
r   r   pytestraisesr   r7   rL   r8   r#   r&   )r   r    r:   r9   actions        r   test_process_templatez"TestFileList.test_process_template   s   J	

 	8F 56 8//78 8	8 J	X?@''76(***f%''76(***F# J	!7CM:	''77CM"::::f%''77CM"::::F# J	X?@''(=>63x="9999f%''(=>63x="9999F# J	!7CM:	''(=>7)+++f%''(=>7)+++F# J	Hs9~s:WX''(BC3x=#j/"BBBBf%''(BC3x=#j/"BBBBF# J	!3x=#i.#j/R	''(BC63y>"::::f%''(BC63y>"::::F# J	Hs:HVW''	23x=#j/"BBBBf%''	23x=#j/"BBBBF# J	!3x=#j/3x=Q	''	263x="9999f%''	263x="9999F#C8 8s   T$$T.	N)__name__
__module____qualname__r#   r&   r-   r=   rG   rM   rS   r[   r_   rd   rn    r   r   r   r   $   s;    

-&+)Z2+7
 , 7$p$r   r   c                   `    e Zd Zej                  d        Zd Zd Zej                  d        Zy)TestFindAllc                 b    t        j                  dd       t        j                         g k(  sJ y )Nfoobar)r   symlinkr   findall)r   temp_cwds     r   test_missing_symlinkz TestFindAll.test_missing_symlink,  s'    


5% !R'''r   c                    t         j                  j                  ddiddid       t        j                  j	                  dd      }t        j                  j	                  dd      }||g}t        t        j                               |k(  sJ y)z
        When findall is called with no parameters or with
        '.' as the parameter, the dot should be omitted from
        the results.
        	file1.txtr2   z	file2.txt)rv   rw   rv   rw   N)jaracopathbuildr   joinsortedr   ry   )r   rz   file1file2expecteds        r   test_basic_discoveryz TestFindAll.test_basic_discovery1  sr     	;"3["<MNOUK0UK05>h&&()X555r   c                     t         j                  j                  ddi|       t        |dz        g}t	        j
                  |      |k(  sJ y)zj
        When findall is called with another path, the full
        path name should be returned.
        r}   r2   N)r~   r   r   strr   ry   )r   tmp_pathr   s      r   test_non_local_discoveryz$TestFindAll.test_non_local_discovery=  sH    
 	;+X6;./0)X555r   c                     t         j                  j                  t         j                  j                  d      dd|       t	        j
                  |      }t        |      dk(  sJ y )N.r2   )zlink-to-parentsomefiler	   )r~   r   r   Symlinkr   ry   len)r   r   r8   s      r   test_symlink_loopzTestFindAll.test_symlink_loopF  sU    "(++"5"5c": 	
   *5zQr   N)	ro   rp   rq   	os_helperskip_unless_symlinkr{   r   r   r   rr   r   r   rt   rt   +  s>    ""( #(
66 ""	 #	r   rt   )__doc__r   r   r)   	distutilsr   r   distutils.errorsr   distutils.filelistr   r   r   jaraco.pathr~   rk   compatr
   r   r4   r   r   rt   rr   r   r   <module>r      sI    #  	 	 % 3 F F   % "
D$ D$N% %r   