
    5hH                    B   U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddl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	e	j        v Zd
 ZdddgdZdedZej        d             Zd Z e  e!eg d                    Z"ddgddgfddgg dfdddgdgfdg ddgfdd gg fd!d"gd#gfd$g d%d&gfd'd(d)gd*gfd+g d,g fd-g d.d/d0gfd1d2d3gg d4fd5g d6d7gfd8d9gg d:fgZ#d;e$d<<   	 ej%        &                    d= e#D                       Z' ej(        e'>          d?             Z)ej%        &                    d@ e#D                       Z* ej(        e*>          dA             Z+dB Z,dC Z- G dD dE          Z. G dF dGe.          Z/ G dH dIe.          Z0dS )Jzsdist tests    )annotationsN)FileListegg_infotranslate_pattern)Distribution)DALS)log)DistutilsTemplateError__pypy__c                B    |                      dt          j                  S )z"Converts '/' in a string to os.sep/)replaceossep)ss    >lib/python3.11/site-packages/setuptools/tests/test_manifest.pymake_local_pathr      s    99S"&!!!    appz0.0)nameversionpackagesz&from setuptools import setup

setup(**z)
c               #  (  K   t           j        t           j        }} t          j                    t          j                    ct           _        t           _        	 d V  | |ct           _        t           _        d S # | |ct           _        t           _        w xY wN)sysstdoutstderrioStringIO)
old_stdout
old_stderrs     r   quietr"   ,   sm       Z
J[]]BKMMCJ
8!+Z
CJJJZ
CJ7777s   A6 6Bc                J    t          | d                                           d S )Nwb)openclose)filenames    r   touchr(   6   s$    4     r   )
README.rstMANIFEST.insetup.pyzapp.egg-info/PKG-INFOzapp.egg-info/SOURCES.txtz!app.egg-info/dependency_links.txtzapp.egg-info/top_level.txtzapp/__init__.pyfoobarfoobarfoo/bar)zfoo/bar/bazz	./foo/barr,   z*.txtzfoo.txtzbar.txtzfoo/foo.txtz	dir/*.txt)zdir/foo.txtzdir/bar.txtzdir/.txtznotdir/foo.txtz*/*.pyzbin/start.pyzdocs/page-?.txtzdocs/page-9.txtzdocs/page-10.txtz
foo/**/bar)zfoo/bing/barzfoo/bing/bang/barr/   zfoo/abarzfoo/**zfoo/bar/bing.pyzfoo/xz/foo/xz**)xzabc/xyzz@nythingzpre[one]post)preopostprenpostpreepostprepost
preonepostzhello[!one]worldhelloxworldhelloyworld)hellooworld
helloworldhellooneworldz
[]one].txt)zo.txtz].txtze.txtzone].txtzfoo[!]one]barfooybar)zfoo]barfooobarfooebarz&list[tuple[str, list[str], list[str]]]translate_specsc              #  b   K   | ]*\  }}}t          t          j        |          |          V  +d S r   zip	itertoolsrepeat.0patternmatches
mismatchess       r   	<genexpr>rI      sQ       - -$* 	!!7++- - - - - -r   )paramsc                6    t          t          | j                  S r   mapr   paramrequests    r   pattern_matchrQ          ...r   c              #  b   K   | ]*\  }}}t          t          j        |          |          V  +d S r   r@   rD   s       r   rI   rI      sQ       0 0$* 	!!:..0 0 0 0 0 0r   c                6    t          t          | j                  S r   rL   rO   s    r   pattern_mismatchrU      rR   r   c                X    | \  }}t          |                              |          sJ d S r   r   match)rQ   rF   targets      r   test_translated_pattern_matchrZ      s3    #OGVW%%++F3333333r   c                X    | \  }}t          |                              |          rJ d S r   rW   )rU   rF   rY   s      r    test_translated_pattern_mismatchr\      s3    &OGV ))//7777777r   c                      e Zd Zd Zd ZdS )TempDirTestCasec                    t          j                    | _        t          j                    | _        t          j        | j                   d S r   )tempfilemkdtemptemp_dirr   getcwdold_cwdchdirselfmethods     r   setup_methodzTempDirTestCase.setup_method   s7     (**y{{
r   c                j    t          j        | j                   t          j        | j                   d S r   )r   re   rd   shutilrmtreerb   rf   s     r   teardown_methodzTempDirTestCase.teardown_method   s,    
dm$$$$$r   N)__name__
__module____qualname__ri   rm    r   r   r^   r^      s2             
% % % % %r   r^   c                  f     e Zd Z f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 Z xZS )TestManifestTestc                "   t                                          |           t          t          j                            | j        d          dd          }|                    t                     |	                                 	 dD ]4}t          t          j                            | j        |                     5t          j                            | j        d          }t          j        |           dD ]/}t          t          j                            ||                     0t          j                            |d          }t          j        |           d	D ]/}t          t          j                            ||                     0d S )
Nr+   wutf-8encoding)r)   .hidden.rsttesting.rstLICENSEr   )z__init__.pya.txtb.txtzc.rststatic)zapp.jsz
app.js.mapzapp.csszapp.css.map)superri   r%   r   pathjoinrb   writeSETUP_PYr&   r(   mkdir)rg   rh   ffnametest_pkgr~   	__class__s         r   ri   zTestManifestTest.setup_method   sT   V$$$dmZ88#PPP						$ M 	6 	6E"',,t}e445555 7<<u55
? 	1 	1E"',,x//0000 h11
G 	/ 	/E"',,vu--....	/ 	/r   c                    t           j                            | j        d          }t	          |dd          5 }|                    t          |                     ddd           dS # 1 swxY w Y   dS )zWrite a MANIFEST.in.r*   ru   rv   rw   N)r   r   r   rb   r%   r   r   )rg   contentsmanifestr   s       r   make_manifestzTestManifestTest.make_manifest   s    7<<}==(C'222 	$aGGDNN###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   #A((A,/A,c                    t          t                    }d|_        t          |          }|                                 |                                 t          |j        j                  S )z7Run egg_info and get all the files to include, as a setr+   )	r   SETUP_ATTRSscript_namer   ensure_finalizedrunsetfilelistfiles)rg   distcmds      r   	get_fileszTestManifestTest.get_files   sT    K((%tnn			3<%&&&r   c                f    t           t          dg          z
  |                                 k    sJ dS )z=Check a missing MANIFEST.in includes only the standard files.r*   N)default_filesr   r   rg   s    r   test_no_manifestz!TestManifestTest.test_no_manifest   s2    ]O 4 449I9IIIIIIIr   c                n    |                      d           t          |                                 k    sJ dS )z<Check an empty MANIFEST.in includes only the standard files. N)r   r   r   r   s    r   test_empty_filesz!TestManifestTest.test_empty_files   s7    2 0 0000000r   c                    |                      d           t          t          ddg          z  }||                                 k    sJ dS )z,Include extra rst files in the project root.zinclude *.rstrz   ry   N)r   r   r   r   )rg   r   s     r   test_includezTestManifestTest.test_include   sN    ?+++]M$B C CC((((((((r   c                    t           }|                     d           t          t           |d          g          z  }||                                 k    sJ dS )z0Include everything in app/ except the text fileszE
            include app/*
            exclude app/*.txt
            	app/c.rstNr   r   r   r   r   rg   mlr   s      r   test_excludezTestManifestTest.test_exclude   sd    	
 	
 	
 RR__$5 6 66((((((((r   c                   t           }|                     d           t          t           |d           |d           |d           |d           |d           |d          g          z  }||                                 k    sJ dS )	zInclude with multiple patterns.zinclude app/*.txt app/static/*	app/a.txt	app/b.txtapp/static/app.jsapp/static/app.js.mapapp/static/app.cssapp/static/app.css.mapNr   r   s      r   test_include_multiplez&TestManifestTest.test_include_multiple   s    ;<<<B{OOB{OOB"##B&''B#$$B'((%
 ! !  ((((((((r   c           	         t           }|                     d           t          t           |d           |d           |d           |d          g          z  }||                                 k    sJ dS )(Include the whole app/static/ directory.zgraft app/staticr   r   r   r   Nr   r   s      r   
test_graftzTestManifestTest.test_graft  s    -...B"##B&''B#$$B'((	%
 ! !  ((((((((r   c           	         t           }|                     d           t          t           |d           |d           |d           |d          g          z  }||                                 k    sJ dS )r   zgraft */staticr   r   r   r   Nr   r   s      r   test_graft_glob_syntaxz'TestManifestTest.test_graft_glob_syntax  s    +,,,B"##B&''B#$$B'((	%
 ! !  ((((((((r   c                    t           }|                     d           t          t           |d           |d          g          z  }||                                 k    sJ dS )z'Exclude all *.map files in the project.zK
            graft app/static
            global-exclude *.map
            r   r   Nr   r   s      r   test_graft_global_excludez*TestManifestTest.test_graft_global_exclude%  st    	
 	
 	
 RR(;%<%<bbAU>V>V$W X XX((((((((r   c           
         t           }|                     d           t          t          dd |d           |d           |d          g          z  }||                                 k    sJ dS )z;Include all *.rst, *.js, and *.css files in the whole tree.z9
            global-include *.rst *.js *.css
            ry   rz   r   r   r   Nr   r   s      r   test_global_includez$TestManifestTest.test_global_include1  s    	
 	
 	

 B{OOB"##B#$$%
 ! !  ((((((((r   c                    t           }|                     d           t          t           |d           |d           |d          g          z  }||                                 k    sJ dS )z@Include all files in app/, except for the whole app/static/ dir.z@
            graft app
            prune app/static
            r   r   r   Nr   r   s      r   test_graft_prunez!TestManifestTest.test_graft_pruneB  sx    	
 	
 	
 RR__bboorr+$W X XX((((((((r   )rn   ro   rp   ri   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   rs   rs      s        %/ %/ %/ %/ %/N$ $ $	' 	' 	'J J J1 1 1
) ) )
) 
) 
)) ) )
) 
) 
)
) 
) 
)
) 
) 
)) ) )"
) 
) 
) 
) 
) 
) 
)r   rs   c                      e Zd ZdZ ej         ej        d          dk              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 Zd Zd Zd Zd ZdS )TestFileListTestz
    A copy of the relevant bits of distutils/tests/test_filelist.py,
    to ensure setuptools' version of FileList keeps parity with distutils.
    SETUPTOOLS_USE_DISTUTILSstdlib)autousec                T    fd}|                     t          j        d|           dS )z Account for stdlib compatibilityc           	         t          j                    }t          j        d|dd|||          }j                            |           d S )N	distutilsr   r   )r   exc_infologging	LogRecordrecordsappend)_loggerlevelmsgargsexcreccaplogs         r   _logz2TestFileListTest._compat_record_logs.<locals>._logY  sF    ,..C#KAsD#NNCN!!#&&&&&r   r   N)setattrr	   Log)rg   monkeypatchr   r   s     ` r   _compat_record_logsz$TestFileListTest._compat_record_logsU  s>    	' 	' 	' 	' 	'
 	CGVT22222r   c                *    fd|j         D             S )Nc                &    g | ]}|j         v |S rq   )levelno)rE   rlevelss     r   
<listcomp>z0TestFileListTest.get_records.<locals>.<listcomp>a  s%    AAAaQY&-@-@-@-@-@r   )r   )rg   r   r   s     `r   get_recordszTestFileListTest.get_records`  s    AAAA6>AAAAr   c                z    |                      |t          j                  g k    sJ |                                 d S r   )r   r	   WARNclearrg   r   s     r   assertNoWarningsz!TestFileListTest.assertNoWarningsc  s6    11R7777r   c                    t           r|j        st          j        d           d S t	          |                     |t          j                            dk    sJ |                                 d S )Nz'caplog checks may not work well in PyPyr   )	IS_PYPYr   pytestxfaillenr   r	   r   r   r   s     r   assertWarningszTestFileListTest.assertWarningsg  sf     	6> 	LBCCCCCt''99::Q>>>>LLNNNNNr   c                    |D ]n}t           j                            | j        |          }t           j                            |          \  }}t          j        |d           t          |           od S )NT)exist_ok)r   r   r   rb   splitmakedirsr(   )rg   r   filedirname	_basenames        r   
make_fileszTestFileListTest.make_filesn  sl     	 	D7<<t44D!#t!4!4GYK$////$KKKK		 	r   c                n   t                      }t          }|                     ddddd |d           |d           |d           |d	           |d
           |d           |d           |d           |d           |d          g           t          d          }|                    d          D ]}|s|                    |           ddd |d           |d           |d           |d           |d           |d          g	}|                                 |j        |k    s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.txta6          include 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
        
)r   r   r   r   r   process_template_linesortr   )rg   	file_listr   MANIFEST_INlinewanteds         r   test_process_template_linez+TestFileListTest.test_process_template_lineu  s   JJ	 	 B%&&B  B  B  B !!BzNNBB !!ByMMB !!#
 	 	 	( 
 
"  %%d++ 	2 	2D ++D1111 B%&&BB !!BzNNB  B  

 	&((((((r   c                H   t                      }|                    d          rJ t                      }ddg|_        |                    d          sJ t                      }ddg|_        |                    d           |                                 |j        dgk    sJ d S )N*.pya.pyzb.pyr|   )r   exclude_patternr   r   rg   r   s     r   test_exclude_patternz%TestFileListTest.test_exclude_pattern  s    JJ	,,V44444 JJ	!6*	((00000 JJ	!7+	!!&)))7)++++++r   c                   t                      }|                     g            |                    d          rJ t                      }|                     ddg           |                    d          sJ t                      }|                     ddg           |                    d           |                                 |j        ddgk    sJ d S )Nr   r   r}   *)r   r   include_patternr   r   r   s     r   test_include_patternz%TestFileListTest.test_include_pattern  s    JJ	,,V44444 JJ	)***((00000 JJ	)***!!#&&&67"3333333r   c                    t                      }dD ]H}t          j        t                    5  |                    |           d d d            n# 1 swxY w Y   Id S )N)	includeexcludezglobal-includezglobal-excludezrecursive-includezrecursive-excludegraftpruneblarg)r   r   raisesr
   r   )rg   r   actions      r   "test_process_template_line_invalidz3TestFileListTest.test_process_template_line_invalid  s    JJ	

 	8 	8F 566 8 8//7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8s   AA	A	c                   |                     t          j                   t          }t	                      }|                     dd |d          g           |                    d           |                                 |j        dgk    sJ | 	                    |           |                    d           |                                 |j        dgk    sJ | 
                    |           d S )Nr   r}   d/c.pyzinclude *.pyzinclude *.rb	set_levelr   DEBUGr   r   r   r   r   r   r   r   rg   r   r   r   s       r   r   zTestFileListTest.test_include  s    '''JJ	""X,,7888''7776(****f%%%''7776(****F#####r   c                   |                     t          j                   t          }t	                      }dd |d          g|_        |                    d           |                                 |j        d |d          gk    sJ |                     |           |                    d           |                                 |j        d |d          gk    sJ | 	                    |           d S )Nr   r}   r  zexclude *.pyzexclude *.rb
r  r   r  r   r   r   r   r   r   r   r  s       r   r   zTestFileListTest.test_exclude  s    '''JJ	!7BBxLL9	''7777BBxLL"99999f%%%''7777BBxLL"99999F#####r   c                   |                     t          j                   t          }t	                      }|                     dd |d          g           |                    d           |                                 |j        d |d          gk    sJ | 	                    |           |                    d           |                                 |j        d |d          gk    sJ | 
                    |           d S )Nr   r}   r  zglobal-include *.pyzglobal-include *.rbr  r  s       r   r   z$TestFileListTest.test_global_include
  s    '''JJ	""X,,7888''(=>>>622h<<"88888f%%%''(=>>>622h<<"88888F#####r   c                   |                     t          j                   t          }t	                      }dd |d          g|_        |                    d           |                                 |j        dgk    sJ |                     |           |                    d           |                                 |j        dgk    sJ | 	                    |           d S )Nr   r}   r  zglobal-exclude *.pyzglobal-exclude *.rbr  r  s       r   test_global_excludez$TestFileListTest.test_global_exclude  s    '''JJ	!7BBxLL9	''(=>>>7)++++f%%%''(=>>>7)++++F#####r   c                R   |                     t          j                   t          }t	                      }|                     d |d           |d           |d          g           |                    d           |                                 |j         |d           |d          gk    sJ | 	                    |           |                    d           |                                 |j         |d           |d          gk    sJ | 
                    |           d S )Nr   d/b.pyd/c.txtd/d/e.pyzrecursive-include d *.pyzrecursive-include e *.pyr  r  s       r   test_recursive_includez'TestFileListTest.test_recursive_include,  s!   '''JJ	Hrr)}}bbnnMNNN''(BCCC22h<<J"@@@@@f%%%''(BCCC22h<<J"@@@@@F#####r   c                   |                     t          j                   t          }t	                      }d |d           |d           |d          g|_        |                    d           |                                 |j        d |d          gk    sJ |                     |           |                    d           |                                 |j        d |d          gk    sJ | 	                    |           d S )Nr   r  r  r  zrecursive-exclude d *.pyzrecursive-exclude e *.pyr  r  s       r   test_recursive_excludez'TestFileListTest.test_recursive_exclude=  s   '''JJ	!22h<<I:O	''(BCCC622i=="99999f%%%''(BCCC622i=="99999F#####r   c                R   |                     t          j                   t          }t	                      }|                     d |d           |d           |d          g           |                    d           |                                 |j         |d           |d          gk    sJ | 	                    |           |                    d           |                                 |j         |d           |d          gk    sJ | 
                    |           d S )Nr   r  r  f/f.pyzgraft dzgraft er  r  s       r   r   zTestFileListTest.test_graftN  s   '''JJ	Hrr*~~rr(||LMMM''	22222h<<J"@@@@@f%%%''	22222h<<J"@@@@@F#####r   c                   |                     t          j                   t          }t	                      }d |d           |d           |d          g|_        |                    d           |                                 |j        d |d          gk    sJ |                     |           |                    d           |                                 |j        d |d          gk    sJ | 	                    |           d S )Nr   r  r  r  zprune dzprune er  r  s       r   
test_prunezTestFileListTest.test_prune_  s   '''JJ	!22h<<JHN	''	222622h<<"88888f%%%''	222622h<<"88888F#####r   N)rn   ro   rp   __doc__r   fixturer   getenvr   r   r   r   r   r   r   r  r  r   r   r   r  r  r  r   r!  rq   r   r   r   r   O  sP        
 V^IBI&@AAXMNNN3 3 ON3B B B      =) =) =)~, , ,"4 4 4$8 8 8"$ $ $"$ $ $"$ $ $"$ $ $"$ $ $"$ $ $"$ $ $"$ $ $ $ $r   r   )1r"  
__future__r   
contextlibr   rB   r   r   rk   r   r`   r   setuptools.command.egg_infor   r   r   setuptools.distr   setuptools.tests.textwrapr   r   r	   distutils.errorsr
   builtin_module_namesr   r   r   r   contextmanagerr"   r(   	frozensetrM   r   r>   __annotations__chainfrom_iterablematch_paramsr#  rQ   mismatch_paramsrU   rZ   r\   r^   rs   r   rq   r   r   <module>r3     s>      " " " " " "     				      				  



   M M M M M M M M M M ( ( ( ( ( ( * * * * * *       3 3 3 3 3 3
0
0" " "   
   8 8 8! ! ! 	C		
 		
 		
  $ UGeX&'@@@Ay)$}o6<<<?O>PQ$*+.@-AB 	888	 		G$	
 	$$$
 	,,,	L! 		&666 	###	 		)))Q-; - - - -\
 ,, - -(7- - -   |$$$/ / %$/ /// 0 0(70 0 0   '''/ / ('/4 4 4
8 8 8
% % % % % % % %a) a) a) a) a) a) a) a)H_$ _$ _$ _$ _$ _$ _$ _$ _$ _$r   