a :êdg¿ã@sdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z Gdd „d e je jejƒZd d „Zed krŒe eƒƒdS) z%Tests for distutils.command.build_py.éN)Úbuild_py)Ú Distribution)ÚDistutilsFileError)Úsupport)Ú run_unittestc@sXeZdZdd„Zdd„Ze ejd¡dd„ƒZ e ejd¡dd „ƒZ d d „Z d d „Z dS)ÚBuildPyTestCasec Cs| ¡}ttj |d¡dƒ}z| d¡W| ¡n | ¡0ttj |d¡dƒ}z| d¡W| ¡n | ¡0| ¡}tdgd|idœƒ}tj |d¡|_t j d |d |j d <dg|_ ddgi|_ d|i|_t|ƒ}d |_| ¡| |j |j ¡| ¡| t| ¡ƒd ¡tj |d¡}t |¡}tj |d¡}| d|¡| d|¡tjrn| tj |¡¡nt |¡} | dtjj| ¡dS)Nú __init__.pyÚwz# Pretend this is a package.z README.txtzInfo about this packageÚpkg)ÚpackagesÚ package_dirúsetup.pyr)ÚforceÚ build_libÚbuildééÚ __pycache__z__init__.%s.pyc)ÚmkdtempÚopenÚosÚpathÚjoinÚwriteÚcloserÚ script_namerZ DummyCommandZ command_objr Ú package_datar rÚcompileZensure_finalizedÚ assertEqualÚrunÚlenZ get_outputsÚlistdirÚassertInÚsysÚdont_write_bytecodeZ assertFalseÚexistsÚimplementationÚ cache_tag) ÚselfÚsourcesÚfZ destinationÚdistÚcmdZpkgdestÚfilesZ pycache_dirZ pyc_files©r.ú9/usr/local/lib/python3.9/distutils/tests/test_build_py.pyÚtest_package_datasL  ÿþ       ÿz!BuildPyTestCase.test_package_datacCsÄ| ¡}ttj |d¡dƒ ¡tj |d¡}t |¡ttj |d¡dƒ ¡t |¡tdgddiddgidœƒ}tj |d ¡|_ d g|_ |  ¡z |  ¡Wnt y¾| d ¡Yn0dS) Nrr ÚdocÚtestfiler Úúdoc/*)r r rr rz/failed package_data test when package_dir is '')rrrrrrÚmkdirÚchdirrrÚ script_argsÚparse_command_lineÚ run_commandsrÚfail)r(r)Ztestdirr+r.r.r/Útest_empty_package_dirDs"  þ  z&BuildPyTestCase.test_empty_package_dirzbyte-compile disabledcCsœ|jdgd\}}t |¡| dd¡t|ƒ}d|_d|_| ¡| ¡t  |j¡}|  t |ƒddg¡t  tj   |jd¡¡}|  |dtjjg¡dS) NÚ boiledeggs©Z py_modulesú boiledeggs.pyúimport antigravityrÚhererzboiledeggs.%s.pyc)Ú create_distrr6Ú write_filerrrÚfinalize_optionsrr!rÚsortedrrr#r&r')r(Ú project_dirr+r,Úfoundr.r.r/Útest_byte_compile[s    ÿz!BuildPyTestCase.test_byte_compilecCs¬|jdgd\}}t |¡| dd¡t|ƒ}d|_d|_d|_| ¡|  ¡t  |j¡}|  t |ƒddg¡t  tj  |jd¡¡}d  tjj¡}|  t |ƒ|g¡dS) Nr<r=r>r?rrr@rzboiledeggs.{}.opt-1.pyc)rArr6rBrrÚoptimizerrCrr!rrDrrÚformatr#r&r')r(rEr+r,rFÚexpectr.r.r/Útest_byte_compile_optimizedls   z+BuildPyTestCase.test_byte_compile_optimizedcCsê| ¡}tj |d¡}t |¡ttj |d¡dƒ ¡tj |d¡}t |¡ttj |d¡dƒ ¡t tj |d¡¡t |¡tdgddgidœƒ}tj |d ¡|_ d g|_ |  ¡z |  ¡Wnt yä| d ¡Yn0d S) zR A directory in package_data should not be added to the filelist. r rr r1r2Zotherdirr4)r rr rz0failed package_data when data dir includes a dirN)rrrrr5rrr6rrr7r8r9rr:)r(r)Zpkg_dirZdocdirr+r.r.r/Útest_dir_in_package_data~s&   ÿ  z(BuildPyTestCase.test_dir_in_package_datacCsr| ¡d}t|ƒ}d|_d|_tj}dt_z| g¡W|t_n|t_0| d|jdd|jdd¡dS)NrTzbyte-compiling is disabledré) rArrrHr#r$Z byte_compiler"Zlogs)r(r+r,Zold_dont_write_bytecoder.r.r/Útest_dont_write_bytecodes  ÿz(BuildPyTestCase.test_dont_write_bytecodeN) Ú__name__Ú __module__Ú __qualname__r0r;ÚunittestZskipIfr#r$rGrKrLrNr.r.r.r/rs1    rcCs t t¡S)N)rRZ makeSuiterr.r.r.r/Ú test_suite¯srSÚ__main__)Ú__doc__rr#rRZdistutils.command.build_pyrZdistutils.corerZdistutils.errorsrZdistutils.testsrZ test.supportrZTempdirManagerZLoggingSilencerZTestCaserrSrOr.r.r.r/Ús      þ!