
    ch,                        d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ dZd Z G d dej        ej                  Z G d dej                  Zedk    r ej                     dS dS )zTests for distutils.filelist.    N)debug)WARN)DistutilsTemplateError)
glob_to_retranslate_patternFileList)filelist)	os_helper)captured_stdout)supportzinclude 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    |                      dt          j                  S )z"Converts '/' in a string to os.sep/)replaceossep)ss    /  /home/conda/feedstock_root/build_artifacts/python-split_1761172146731/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.11/distutils/tests/test_filelist.pymake_local_pathr      s    99S"&!!!    c                   P    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dS )FileListTestCasec                     |                      |                     t                    g            |                                  d S )N)assertEqualget_logsr   
clear_logsselfs    r   assertNoWarningsz!FileListTestCase.assertNoWarnings'   s:    t,,b111r   c                     |                      t          |                     t                              d           |                                  d S )Nr   )assertGreaterlenr   r   r   r   s    r   assertWarningszFileListTestCase.assertWarnings+   sB    3t}}T2233Q777r   c                     t           j        }t           j        dk    rt          j        t           j                  }dD ]/\  }}|d|iz  }|                     t          |          |           0d S )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   r   globregexs       r   test_glob_to_rez FileListTestCase.test_glob_to_re/   sv    f6T>>)BF##C	A 	6 	6KD% UCL(EZ--u5555	6 	6r   c                 ^   t                      }t          }ddddd |d           |d           |d           |d	           |d
           |d           |d           |d           |d           |d          g|_        t                              d          D ]0}|                                dk    r|                    |           1ddd |d           |d           |d           |d           |d           |d          g	}|                     |j        |           d S )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_liner   files)r   	file_listllinewanteds        r   test_process_template_linez+FileListTestCase.test_process_template_lineA   s{   JJ	 (tZ,  a 677a 011a 011a 011a 122a
mma00a 122a	lla 122	   %%d++ 	2 	2Dzz||r!!++D1111 !*++!$%%!$%%!J--!O$$!%&&	 	&11111r   c                    t                      }t                      5 }|                    d           d d d            n# 1 swxY w Y   |                     |                                d           dt
          _        	 t                      5 }|                    d           d d d            n# 1 swxY w Y   |                     |                                d           dt
          _        d S # dt
          _        w xY w)Nxxxr.   Tzxxx
F)r   r   debug_printr   getvaluer   DEBUG)r   r5   stdouts      r   test_debug_printz!FileListTestCase.test_debug_printi   sY   JJ	 	)&!!%(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)**B///	  "" -f%%e,,,- - - - - - - - - - - - - - -V__..888EKKK%EKs?   ?AA?C0 B/#C0 /B33C0 6B37+C0 0C>c                     t                      }g d}|                    |           |                     |j        |           d S )N)abc)r   set_allfilesr   r/   )r   r5   r4   s      r   test_set_allfilesz"FileListTestCase.test_set_allfilesw   sG    JJ	u%%%+U33333r   c                     t                      }g d|_        |                                 |                                 |                     |j        g d           d S )N)rB   rC   rB   grD   rH   )rB   rC   rD   rH   )r   r4   sortremove_duplicatesr   r   r5   s     r   test_remove_duplicatesz'FileListTestCase.test_remove_duplicates}   s_    JJ	888	##%%%*>*>*>?????r   c           	         |                      t          t          ddd          d                     t          j        d          }|                     t          |dd          |           |                      t          t          ddd          d                     |                      t          ddd                              d                     d S )NrB   TF)anchoris_regexsearch*.pyzfilelist.py)
assertTruehasattrr   r%   compiler   rP   )r   r(   s     r   test_translate_patternz'FileListTestCase.test_translate_pattern   s    c$???  	 	 	
 
3eD4@@@	 	 	
 	c$>>>  	 	 	
 	)4%1 1 1171F1F	H 	H 	H 	H 	Hr   c                    t                      }|                     |                    d                     t                      }ddg|_        |                     |                    d                     t                      }ddg|_        |                    d           |                     |j        dg           d S )NrQ   a.pyzb.pyza.txt)r   assertFalseexclude_patternr4   rR   r   rK   s     r   test_exclude_patternz%FileListTestCase.test_exclude_pattern   s    JJ	226::;;; JJ	!6*		11&99::: JJ	!7+	!!&)))7)44444r   c                    t                      }|                    g            |                     |                    d                     t                      }|                    ddg           |                     |                    d                     t                      }|                     |j                   |                    ddg           |                    d           |                     |j        ddg           d S )NrQ   rW   b.txt*)r   rE   rX   include_patternrR   assertIsNoner/   r   rK   s     r   test_include_patternz%FileListTestCase.test_include_pattern   s    JJ	r"""226::;;; JJ	0111	11&99::: JJ	),---0111!!#&&&+fg->?????r   c                 l   t           }t                      }dD ]#}|                     t          |j        |           $t                      }|                    dd |d          g           |                    d           |                     |j        dg           |                                  |                    d           |                     |j        dg           | 	                                 t                      }dd |d          g|_        |                    d           |                     |j        d |d          g           |                                  |                    d           |                     |j        d |d          g           | 	                                 t                      }|                    dd |d          g           |                    d	           |                     |j        d |d          g           |                                  |                    d
           |                     |j        d |d          g           | 	                                 t                      }dd |d          g|_        |                    d           |                     |j        dg           |                                  |                    d           |                     |j        dg           | 	                                 t                      }|                    d |d           |d           |d          g           |                    d           |                     |j         |d           |d          g           |                                  |                    d           |                     |j         |d           |d          g           | 	                                 t                      }d |d           |d           |d          g|_        |                    d           |                     |j        d |d          g           |                                  |                    d           |                     |j        d |d          g           | 	                                 t                      }|                    d |d           |d           |d          g           |                    d           |                     |j         |d           |d          g           |                                  |                    d           |                     |j         |d           |d          g           | 	                                 t                      }d |d           |d           |d          g|_        |                    d           |                     |j        d |d          g           |                                  |                    d           |                     |j        d |d          g           | 	                                 d S )N)	includeexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludegraftpruneblargrW   r\   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   assertRaisesr   r3   rE   r   r4   r   r"   )r   r6   r5   actions       r   test_process_templatez&FileListTestCase.test_process_template   s   JJ	G 	G 	GF 4'=vG G G G JJ	8=>>>''7776(333''7776(333 JJ	!7AAhKK8	''7777AAhKK*@AAA''7777AAhKK*@AAA JJ	8=>>>''(=>>>611X;;*?@@@''(=>>>611X;;*?@@@ JJ	!7AAhKK8	''(=>>>7)444''(=>>>7)444 JJ	(QQy\\ !* / 	0 	0 	0 	''(BCCC11X;;**FGGG''(BCCC11X;;**FGGG JJ	!11X;;)aa
mmL	''(BCCC611Y<<*@AAA''(BCCC611Y<<*@AAA JJ	(QQz]] !( - 	. 	. 	. 	''	22211X;;**FGGG''	22211X;;**FGGG JJ	!11X;;*qq{{K	''	222611X;;*?@@@''	222611X;;*?@@@r   N)__name__
__module____qualname__r   r"   r)   r9   r@   rF   rL   rU   rZ   r`   ri    r   r   r   r   $   s            6 6 6$&2 &2 &2P     4 4 4@ @ @H H H*5 5 5 @ @ @$j j j j jr   r   c                   :    e Zd Zej        d             Zd Zd ZdS )FindAllTestCasec                     t          j                    5  t          j        dd           |                     t          j                    g            d d d            d S # 1 swxY w Y   d S )Nfoobar)r
   temp_cwdr   symlinkr   r	   findallr   s    r   test_missing_symlinkz$FindAllTestCase.test_missing_symlink*  s    !! 	5 	5Jue$$$X-//444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   =AA"%A"c                    t          j                    5  t          j        d           t          j                            dd          }t          j        |           t          j        d           t          j                            dd          }t          j        |           ||g}|                     t          t          j
                              |           ddd           dS # 1 swxY w Y   dS )z
        When findall is called with no parameters or with
        '.' as the parameter, the dot should be omitted from
        the results.
        rq   	file1.txtrr   z	file2.txtN)r
   rs   r   mkdirpathjoincreate_empty_filer   sortedr	   ru   )r   file1file2expecteds       r   test_basic_discoveryz$FindAllTestCase.test_basic_discovery0  s!    !! 	C 	CHUOOOGLL44E'...HUOOOGLL44E'...u~HVH$4$6$677BBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs   C	C**C.1C.c                    t          j                    5 }t          j                            |d          }t          j        |           |g}|                     t          j        |          |           ddd           dS # 1 swxY w Y   dS )zj
        When findall is called with another path, the full
        path name should be returned.
        rx   N)	r
   temp_dirr   rz   r{   r|   r   r	   ru   )r   r   r~   r   s       r   test_non_local_discoveryz(FindAllTestCase.test_non_local_discovery@  s    
 !! 	CXGLL;77E'...wHX-h77BBB		C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs   A BBBN)rj   rk   rl   r
   skip_unless_symlinkrv   r   r   rm   r   r   ro   ro   )  sW        "5 5 #"5
C C C 	C 	C 	C 	C 	Cr   ro   __main__)__doc__r   r%   unittest	distutilsr   distutils.logr   distutils.errorsr   distutils.filelistr   r   r   r	   test.supportr
   r   distutils.testsr   r0   r   LoggingSilencerTestCaser   ro   rj   mainrm   r   r   <module>r      sp   # # 				 				              3 3 3 3 3 3 F F F F F F F F F F       " " " " " " ( ( ( ( ( ( # # # # # # " " "
B B B B Bw.(B B BJ C  C  C  C  Ch'  C  C  CF zHMOOOOO r   