a  ze,@sdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z ddlmZddlZddlmZmZdd lmZd Zd d ZGd ddejejZGdddejZddZedkreedS)zTests for distutils.filelist.N)debug)WARN)DistutilsTemplateError) glob_to_retranslate_patternFileList)filelist)captured_stdout run_unittest)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 cCs|dtjS)z"Converts '/' in a string to os.sep/)replaceossep)srQ/opt/bitninja-python-dojo/embedded/lib/python3.9/distutils/tests/test_filelist.pymake_local_pathsrc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)FileListTestCasecCs||tg|dSN) assertEqualget_logsr clear_logsselfrrrassertNoWarnings'sz!FileListTestCase.assertNoWarningscCs"|t|td|dS)Nr)Z assertGreaterlenrrrrrrrassertWarnings+szFileListTestCase.assertWarningscCsJtj}tjdkrttj}dD]$\}}|d|i}|t||q dS)N\))zfoo*z(?s:foo[^%(sep)s]*)\Z)zfoo?z(?s:foo[^%(sep)s])\Z)zfoo??z(?s:foo[^%(sep)s][^%(sep)s])\Z)zfoo\\*z(?s:foo\\\\[^%(sep)s]*)\Z)zfoo\\\*z(?s:foo\\\\\\[^%(sep)s]*)\Z)zfoo????z2(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z)zfoo\\??z"(?s:foo\\\\[^%(sep)s][^%(sep)s])\Zr)rrreescaperr)rrglobregexrrrtest_glob_to_re/s    z FileListTestCase.test_glob_to_recCst}t}ddddd|d|d|d|d |d |d |d |d |d|dg|_tdD]}|dkrrq`||q`ddd|d|d|d|d |d |d g }||j|dS)Nzfoo.tmpokZxozfour.txtz buildout.cfgz.hg/last-message.txtzglobal/one.txtzglobal/two.txtzglobal/files.xzglobal/here.tmpzf/o/f.ooz dir/graft-onezdir/dir2/graft2zdir3/okzdir3/sub/ok.txt ) rrallfiles MANIFEST_INsplitstripprocess_template_linerfiles)r file_listllineZwantedrrrtest_process_template_lineAs<   z+FileListTestCase.test_process_template_linecCst}t}|dWdn1s,0Y||ddt_zJt}|dWdn1st0Y||dWdt_ndt_0dS)NZxxxr&Tzxxx F)rr Z debug_printrgetvaluerDEBUG)rr-stdoutrrrtest_debug_printis((z!FileListTestCase.test_debug_printcCs*t}gd}||||j|dS)N)abc)r set_allfilesrr')rr-r,rrrtest_set_allfilesws z"FileListTestCase.test_set_allfilescCs6t}gd|_||||jgddS)N)r5r6r5gr7r:)r5r6r7r:)rr,sortZremove_duplicatesrrr-rrrtest_remove_duplicates}s  z'FileListTestCase.test_remove_duplicatescCsr|ttdddddtd}|t|ddd||ttddddd|tddddddS)Nr5TF)anchorZis_regexsearch*.pyz filelist.py) assertTruehasattrrrcompilerr?)rr"rrrtest_translate_patterns$    z'FileListTestCase.test_translate_patterncCsdt}||dt}ddg|_||dt}ddg|_|d||jdgdS)Nr@a.pyzb.pyza.txt)r assertFalseZexclude_patternr,rArr<rrrtest_exclude_patterns   z%FileListTestCase.test_exclude_patterncCst}|g||dt}|ddg||dt}||j|ddg|d||jddgdS)Nr@rEb.txt*)rr8rFZinclude_patternrAZ assertIsNoner'rr<rrrtest_include_patterns   z%FileListTestCase.test_include_patterncCst}t}dD]}|t|j|qt}|dd|dg|d||jdg||d||jdg| t}dd|dg|_|d||jd|dg||d||jd|dg| t}|dd|dg|d ||jd|dg||d ||jd|dg| t}dd|dg|_|d ||jdg||d ||jdg| t}|d|d |d|dg|d||j|d |dg||d||j|d |dg| t}d|d |d|dg|_|d||jd|dg||d||jd|dg| t}|d|d |d|dg|d||j|d |dg||d||j|d |dg| t}d|d |d|dg|_|d||jd|dg||d||jd|dg| dS)N) ZincludeZexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludeZgraftZpruneZblargrErHzd/c.pyz include *.pyz include *.rbz exclude *.pyz exclude *.rbzglobal-include *.pyzglobal-include *.rbzglobal-exclude *.pyzglobal-exclude *.rbzd/b.pyzd/c.txtzd/d/e.pyzrecursive-include d *.pyzrecursive-include e *.pyzrecursive-exclude d *.pyzrecursive-exclude e *.pyzf/f.pyzgraft dzgraft ezprune dzprune e) rrZ assertRaisesrr+r8rr,rr)rr.r-actionrrrtest_process_templates                z&FileListTestCase.test_process_templateN)__name__ __module__ __qualname__rrr#r0r4r9r=rDrGrJrLrrrrr$s(rc@s,eZdZejjddZddZddZdS)FindAllTestCasecCsJtj,tdd|tgWdn1s<0YdS)Nfoobar)testr temp_cwdrsymlinkrrfindallrrrrtest_missing_symlink*s  z$FindAllTestCase.test_missing_symlinkcCstjttdtjdd}tj|tdtjdd}tj|||g}|t t |Wdn1s0YdS)z When findall is called with no parameters or with '.' as the parameter, the dot should be omitted from the results. rQ file1.txtrRz file2.txtN) rSr rTrmkdirpathjoincreate_empty_filersortedrrV)rfile1Zfile2expectedrrrtest_basic_discovery0s     z$FindAllTestCase.test_basic_discoverycCs`tjB}tj|d}tj||g}|t ||Wdn1sR0YdS)zj When findall is called with another path, the full path name should be returned. rXN) rSr temp_dirrrZr[r\rrrV)rrar^r_rrrtest_non_local_discovery@s   z(FindAllTestCase.test_non_local_discoveryN) rMrNrOrSr Zskip_unless_symlinkrWr`rbrrrrrP)s rPcCstttttgSr)unittestZ TestSuiteZ makeSuiterrPrrrr test_suiteLsrd__main__)__doc__rrrcZ distutilsrZ distutils.logrZdistutils.errorsrZdistutils.filelistrrrrZ test.supportrSr r Zdistutils.testsr r(rZLoggingSilencerZTestCaserrPrdrMrrrrs,     #