a zed@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZmZzddlmZdZWneydZYn0ddlmZddlmZdd lmZdd lmZd d Zd dZddZ GdddZ!Gddde!ej"eddZ#Gddde!ej"eddZ$Gdddej"Z%GdddZ&Gddde&ej"eddZ'Gddde&ej"eddZ(Gd d!d!Z)Gd"d#d#e)ej"eddZ*Gd$d%d%e)ej"eddZ+e,d&kre-dS)'N)mock skipUnless)ProcessPoolExecutorTF)support) script_helper)without_source_date_epoch)SourceDateEpochTestMetacCs|sd}tjj||dS)N optimization) importlibutilcache_from_source)scriptoptrH/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_compileall.pyget_pyc srcsfdddDS)Ncsg|]}t|qSr)r).0rrrr (zget_pycs..rrrrrrrget_pycs'srcCs t|j}t|j}||kSN)osstatst_ino)Z filename1 filename2Zinode1Zinode2rrr is_hardlink+s  r!c@sheZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zed#d$d%Zd&d'Zed#d(d)Zed#ed*d+d,Zejd#d-d.ed*d/d0Zd1d2Zd3d4d5d6Zd7d8Zd9d:Zd;d<Zd=d>Z d?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%e&j'dIdJZ(d-S)KCompileallTestsBasecCst|_tj|jd|_tj |j|_ t |jd}| dWdn1sX0Ytj|jd|_ tj |j |_t|j|j tj|jd|_t|jtj|jd|_t|j|jdS)N_test.pywzx = 123 z _test2.pyZ_subdirz _test3.py)tempfilemkdtemp directoryrpathjoin source_pathr rrbc_pathopenwrite source_path2bc_path2shutilcopyfileZ subdirectorymkdir source_path3selffilerrrsetUp4s ( zCompileallTestsBase.setUpcCst|jdSrr0rmtreer'r5rrrtearDownBszCompileallTestsBase.tearDowncCsLtj|jd|_t|jd}|dWdn1s>0YdS)Nz _test_bad.pyr$zx ( )rr(r)r'bad_source_pathr,r-r4rrradd_bad_source_fileEsz'CompileallTestsBase.add_bad_source_filecCsht|jd}|d}Wdn1s,0Ytt|jj}t dt j j d|d@}||fS)Nrb <4sLLr) r,r+readintrrr*st_mtimestructpackr r MAGIC_NUMBER)r5r6datamtimeZcomparerrrtimestamp_metadataJs(z&CompileallTestsBase.timestamp_metadatac Csxzt|jdWn ttfy2|dYn0tt "| t |jWdn1sj0YdS)N)rArAz0filesystem doesn't support timestamps near 2**32 rutimer* OverflowErrorOSErrorZskipTest contextlibredirect_stdoutioStringIO assertTrue compileall compile_filer:rrr test_year_2038_mtime_compilationRs z4CompileallTestsBase.test_year_2038_mtime_compilationc Csxzt|jdWn ttfy2|dYn0tt "| t |jWdn1sj0YdS)N) rWz+filesystem doesn't support large timestampsrKr:rrrtest_larger_than_32_bit_times\s z1CompileallTestsBase.test_larger_than_32_bit_timescCstjdrtdt|j|j| t |j d$}| t |d}Wdn1sf0Yt |j d$}||||Wdn1s0Y|j| tj|jddd|j| dS)NSOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setr>wbFTforcequiet)renvirongetunittestSkipTest py_compilecompiler* assertEqualrJr,r+rBlenr-assertNotEqualrT compile_dirr'rS)r5metadatar6bcrrrrecreation_checkfs   2 (z$CompileallTestsBase.recreation_checkcCs|tdtjjdddS)Nr@rr)rjrErFr rrGr:rrr test_mtimevszCompileallTestsBase.test_mtimecCs|ddS)Ns)rjr:rrrtest_magic_number{sz%CompileallTestsBase.test_magic_numbercCs|j|jfD] }zt|Wq Yq 0q |tj|jddd|tj |joftj |j t|j|tj |j ddd|tj |jotj |jt|jt|j| | tj|jddd| tj |j ddddS)NFTr[r)r+r/runlinkrSrTrUr*r(isfilergr'r= assertFalser<)r5fnrrrtest_compile_filess6       z&CompileallTestsBase.test_compile_filescCs||tj|jt(}|t t |j Wdn1sJ0Y| |d|tj|jdS)Nz&Compiling ([^WindowsPath|PosixPath].*))rorr(rnr+rcaptured_stdoutrSrTrUpathlibPathr* assertRegexgetvalue)r5stdoutrrrtest_compile_file_pathlikes  6z.CompileallTestsBase.test_compile_file_pathlikecCsP|tj|j|tjt |j t ddd|tj|jdS)NZ ddir_pathr)ddirr]) rorr(rnr+rSrTrUrsrtr*r:rrrtest_compile_file_pathlike_ddirs z3CompileallTestsBase.test_compile_file_pathlike_ddircCstjjj|jgd"|tjddWdn1s<0Ytjjj|jgd.|| tjddddWdn1s0YdS)Nr(rr]FT) skip_curdirr\r]) testtest_importlibrZ import_stater'rSrT compile_pathr=ror:rrrtest_compile_paths0 z%CompileallTestsBase.test_compile_pathcCs|tj|jd}tj|d}t|t|dWdn1sH0Yt||tj tj|ddS)NrHr6r$ __pycache__) rr(r)r'r2r,rTrUroexists)r5Zdata_dirZ data_filerrrtest_no_pycache_in_non_packages   z2CompileallTestsBase.test_no_pycache_in_non_packagecCsL|tt"|t|jWdn1s>0YdSr) r=rOrPrQrRrorTrUr<r:rrr#test_compile_file_encoding_fallbacksz7CompileallTestsBase.test_compile_file_encoding_fallbackcCsdrdnd\}}tj|jd|dtjj|j|d}|tj |tjj|j |d}|tj |tjj|j |d}|tj |dS)NF)rr)rr Tr]optimizer ) rTrgr'r rrr*rSrr(rnr.r3)r5rrcachedZcached2Zcached3rrr test_optimizes   z!CompileallTestsBase.test_optimizecCs|tj|jt"}tt |j Wdn1sD0Y| d}||d|tj|jdS)Nrz$Listing ([^WindowsPath|PosixPath].*))rorr(rnr+rrrrTrgrsrtr'rv splitlinesrurS)r5rwlinerrrtest_compile_dir_pathlikes  0 z-CompileallTestsBase.test_compile_dir_pathlikez&concurrent.futures.ProcessPoolExecutorcCs"tj|jddd||jdSNTr]workersrTrgr'rScalledr5 pool_mockrrrtest_compile_pool_calledsz,CompileallTestsBase.test_compile_pool_calledcCs@|td tj|jddWdn1s20YdS)Nz%workers must be greater or equal to 0)r)ZassertRaisesRegex ValueErrorrTrgr'r:rrr!test_compile_workers_non_positivesz5CompileallTestsBase.test_compile_workers_non_positivecCs,tj|jddd||jddddS)NTrrr max_workers)rTrgr'rd call_argsrrrrtest_compile_workers_cpu_countsz2CompileallTestsBase.test_compile_workers_cpu_countzcompileall.compile_filecCs,tj|jdd||j||jdS)NTr|)rTrgr'rorrS)r5compile_file_mockrrrrtest_compile_one_workers z+CompileallTestsBase.test_compile_one_workerNnewcCs"tj|jddd||jdSrr)r5rrrr$test_compile_missing_multiprocessingsz8CompileallTestsBase.test_compile_missing_multiprocessingcCsd}|j}td|dD]>}tj|d|}tj|d}t|t|j|qt j |}t j |jd|dd|tj|t j |jd|d|tj|dS)NrZdir_z script.pyT)r] maxlevels)r'rangerr(r)r2r0r1r*r rrrTrgrornrS)r5depthr(isourceZ pyc_filenamerrrtest_compile_dir_maxlevelss  z.CompileallTestsBase.test_compile_dir_maxlevelsT)parallelcCsddg}|j}g}|D]>}tj||}t|t|dd|t|ddqtj |jd||rjdnd d | ||D]}| | |j|t j |}|t|jtjd} t|\} } } tj|| } tjj |} || j| |d | d t| qdS) Nr~foo__init__r modzdef fn(): 1/0 fn() Trr)r]ryr")r'rr(r)r2r make_scriptappendrTrgrS startswithr rrresepassert_python_failurer~rZget_code_from_pycrd co_filenameassertInfsdecode)r5ryrfullpathr(ZmodsZsubdirrZmodcodemodpath_err expected_inZ mod_code_objrrr_test_ddir_onlys0     z#CompileallTestsBase._test_ddir_onlycCs|jdddS)N Fryrrr:rrrtest_ddir_only_one_worker!sz-CompileallTestsBase.test_ddir_only_one_workercCs|jdddS)NrTrrr:rrrtest_ddir_multiple_workers%sz.CompileallTestsBase.test_ddir_multiple_workerscCs|jdddS)Nr Frrr:rrrtest_ddir_empty_only_one_worker)sz3CompileallTestsBase.test_ddir_empty_only_one_workercCs|jdddS)Nr Trrr:rrr test_ddir_empty_multiple_workers-sz4CompileallTestsBase.test_ddir_empty_multiple_workersc Csgd}tjj|jg|R}t|t|dd}tj |}tjj|jg|ddR}t j |d|dt |\}}}tjj|dd} | | t|td||t|tddS)Nr~buildrealr(r~1 / 0rT)r]stripdirencodingrr(r)r'makedirsrrr rrrTrgrrstrsysgetdefaultencoding assertNotIn) r5rr(rrirrcoutrrrrrtest_strip_only1s"  z#CompileallTestsBase.test_strip_onlyc Csgd}tjj|jg|R}t|t|dd}tj |}d}t j |d|dt |\}}}tjj||jg|R} | | t|tddS)Nrr~r/fooT)r] prependdirr)rr(r)r'rrrr rrrTrgrrrrr) r5rr(rrirrrrrrrrtest_prepend_onlyDs  z%CompileallTestsBase.test_prepend_onlyc Csgd}tjj|jg|R}t|t|dd}tj |}tjj|jg|ddR}d}t j |d||dt |\}}} tjj|g|ddR} | | t| td||t| tddS) Nrr~rrrT)r]rrrr r5rr(rrirrrrrrrrrtest_strip_and_prependSs(  z*CompileallTestsBase.test_strip_and_prependcCsxgd}tjj|jg|R}t|t|dd|t$t j |dddddWdn1sj0YdS)N)r~rrr(ryr~rTz/barr)r]ryrr) rr(r)r'rrr assertRaisesrrTrg)r5rr(rrrtest_strip_prepend_and_ddirhs   z/CompileallTestsBase.test_strip_prepend_and_ddirc Cst|jdd}g}dD]}|tjj||dqddgddgddggdg}|D]Z}tj|d |d |D]@}| t j ||zt ||WqltyYql0qlqTdS) Ntest_optimizationa = 0r rrrr rrrrTr)rrr'rr rrrTrUrSrr(rnrm Exception)r5rri opt_leveltest_combinationsopt_combinationrrr!test_multiple_optimization_levelsqs(   z5CompileallTestsBase.test_multiple_optimization_levelsc Cstj|jddd}tj|jddd}tj|jddd}t|t|t|t|dd}t|dd}tj|d }tj|d }t||t||tj |}tj |} t j |d |d | tj||tj| dS) Nr~dirallowedsymlinks prohibited test_allowedrtest_prohibitedtest_allowed.pytest_prohibited.pyT)r] limit_sl_dest)rr(r)r'rrrsymlinkr rrrTrgrSrnro r5Z allowed_pathZ symlinks_pathZprohibited_pathZallowed_scriptZprohibited_scriptZallowed_symlinkZprohibited_symlinkZ allowed_bcZ prohibited_bcrrrtest_ignore_symlink_destinations"       z3CompileallTestsBase.test_ignore_symlink_destination))__name__ __module__ __qualname__r7r;r=rJrVrXrjrkrlrqrxrzrrrrrrpatchrrrrrrrrrrrrrrrrrskip_unless_symlinkrrrrrr"2sR          r"c@s eZdZdS)CompileallTestsWithSourceEpochNrrrrrrrrsr) metaclassZsource_date_epochc@s eZdZdS)!CompileallTestsWithoutSourceEpochNrrrrrrsrc@s$eZdZddZddZddZdS) EncodingTestcCsdt|_tj|jd|_t|jddd$}|d|dWdn1sV0YdS)Nr#r$utf-8rz# -*- coding: utf-8 -*- u print u"€" ) r%r&r'rr(r)r*r,r-r4rrrr7s   zEncodingTest.setUpcCst|jdSrr8r:rrrr;szEncodingTest.tearDowncCs>z0tj}tjtddt_t|jW|t_n|t_0dS)Nasciir)rrwrQ TextIOWrapperBytesIOrTrgr')r5Z orig_stdoutrrr test_errors zEncodingTest.test_errorN)rrrr7r;rrrrrrsrc@seZdZeddZddZddZddZd d Zd d Z d dZ ddZ ddZ e ddZddZddgfdddgfdddgffD]&\ZZZeefdd Zeed!e<qd"d#Zd$d%Ze d&d'Zd(d)Zd*d+Zejd,d-Zd.d/Zd0d1Zd2d3Zd4d5Z d6d7Z!d8d9Z"d:d;Z#dd?Z%d@dAZ&dBdCZ'dDdEZ(dFdGZ)e*e+dHdIdJZ,e-.dKdLdMZ/dNdOZ0dPdQZ1ejdRdSZ2dTdUZ3dVdWZ4dXS)YCommandLineTestsBasec CsttjjtjD]}d}t|d}|d}zzL|sF|d}| d}| dWdn1sp0YWn8t yd}YWt t||r|qYn0Wt t||r|qt t||r|0qd}||_dS)NFrztest.tryTr$z# for test_compileall)filterrr(isdirrrsrtis_dirr2r,r-rNrrmrrmdir_sys_path_writable)clsr(Zdirectory_createdr'r6Zsys_path_writablerrr setUpClasss2 ,    zCommandLineTestsBase.setUpClasscCs|jstddS)Nz(not all entries on sys.path are writable)rr`rar:rrr_skip_if_sys_path_not_writablesz3CommandLineTestsBase._skip_if_sys_path_not_writablecCsgtddd|S)Nz-S-mrT)rZ!optim_args_from_interpreter_flags)r5argsrrr _get_run_argss z"CommandLineTestsBase._get_run_argscOs4tj||i|ddi\}}}|d||S)NPYTHONIOENCODINGrr)rassert_python_okrrdr5rZenv_varsrrrrrr assertRunOKs z CommandLineTestsBase.assertRunOKcOs.tj||i|ddi\}}}|||fS)Nrr)rrrr rrrassertRunNotOKsz#CommandLineTestsBase.assertRunNotOKcCs"tj|}|tj|dSr)r rrrSrr(rr5rpr(rrrassertCompileds z#CommandLineTestsBase.assertCompiledcCs"tj|}|tj|dSr)r rrrorr(rr rrrassertNotCompileds z&CommandLineTestsBase.assertNotCompiledcCsrt|_|tj|jtj|jd|_ t |j tj|j d|_ t |j dd|_t |j dd|_dS)Nrrrr Zbar)r%r&r'Z addCleanuprr9rr(r)pkgdirr2pkgdir_cachedirrrinitfnbarfnr:rrrr7s  zCommandLineTestsBase.setUpcCsL|t|jdd}|j|jd||||j||jdS)Nbazr  PYTHONPATH) rrrr'r rrrr)r5bazfnrrrtest_no_args_compiles_paths   z/CommandLineTestsBase.test_no_args_compiles_pathcCs|t|jdd}|j|jdtj|}t |t dfdt |j }|j|jdt |j }| |||jd|jdt |j }|||dS)Nrr r<r-f)rrrr'r r rrrrLtimerrDrdrf)r5rpycpathrImtime2rrr test_no_args_respects_force_flags     z5CommandLineTestsBase.test_no_args_respects_force_flagcCsR|t|jdd|j|jd}|d||jd|jd}|d|dS)Nrr rsListing -q)rrrr'r rrr5Znoisyr]rrr test_no_args_respects_quiet_flag s  z5CommandLineTestsBase.test_no_args_respects_quiet_flagZnormalpycrz opt-1.pyc-OZdoubleoptimizez opt-2.pycz-OOcs~tj|ddd|jg|tj|jtfdddD}| tt |j|| fddt |jDdS) NrrTrc3s|]}|tjjVqdSr)formatrimplementation cache_tag)rbaseextrr 4sz)CommandLineTestsBase.f..)z__init__.{}.{}z bar.{}.{}csg|]}|r|qSr)endswith)rrpr(rrr8s z*CommandLineTestsBase.f..) rr rrSrr(rrsortedrdlistdirro)r5r)switchexpectedrr(rf/s  zCommandLineTestsBase.fZtest_pep3147_paths_cCsL|dd|j|tj|jtgd}|tt |j|dS)Nz-br) __init__.pyz __init__.pyczbar.pyzbar.pyc) r rrorr(rrr,rdr-)r5r/rrrtest_legacy_paths<s z&CommandLineTestsBase.test_legacy_pathscCs||d|j|tj|jtj|jd}|tj||d|j|tj|j|tj|dS)Nrr) r rrSrr(rrr)ro)r5Z cachecachedirrrrtest_multiple_runsFsz'CommandLineTestsBase.test_multiple_runscCs|d|jtj|j}t|tdfdt |j }|d|jt |j }| |||dd|jt |j }| ||dS)Nrrrr) r rr rrrrrLrrrDrdrf)r5rrIrrrr test_forceSs    zCommandLineTestsBase.test_forcecCstj|jd}t|t|dd}t|dd}|dd|j||| tj tj|d|d|j| || |dS)Nspamrr hamrz-lr) rr(r)rr2rrr rrorr)r5 subpackage subinitfnhamfnrrrtest_recursion_controlcs   z+CommandLineTestsBase.test_recursion_controlc CsVtj|jd}tj|d}tj|d}|||fD]}t|q6tj|d}t|dd}t|dd}t|dd}|dd|j||| tj tj|d |dd |j| || ||||dd |j| || || ||||dd |j| || || || |dS) Nr5r6Zeggsr1r Zeggrz-r 0rz-r 1z-r 2z-r 5) rr(r)rrmake_pkgrr rrorr) r5r7Z subpackage2Z subpackage3pkgr8r9ZspamfnZeggfnrrrtest_recursion_limitos8            z)CommandLineTestsBase.test_recursion_limitc Csttj|jd}t|tdtj|dtdtj|d|d|j|tj|jdddddS)Nr5.ZevilZevil2rr1) rr(r)rrr;rr r)r5r<rrrtest_symlink_loops   z&CommandLineTestsBase.test_symlink_loopcCs6||j}|d|j}|d||d|dS)Nrr)r rrfrdr rrr test_quiets  zCommandLineTestsBase.test_quietcCsTt|jdd|d|j\}}}|d|j\}}}|d||d|dS)N crunchyfrog bad(syntaxrz-qqr)rrrr rfrd)r5rr]Zsilentrrr test_silents  z CommandLineTestsBase.test_silentcCs.|ddd|j||j||jdS)Nrz-xz ba[^\\/]*$)r rrrrrr:rrr test_regexps z CommandLineTestsBase.test_regexpcCsvtj|jd}t|t|dd}t|dd}|d|j|| |j | |j | || |dS)NZfoo2rr bar2r) rr(r)r'r2rrr rrrr)r5Zpkgdir2Zinit2fnbar2fnrrrtest_multiple_dirss    z'CommandLineTestsBase.test_multiple_dirscCs8t|jdd|ddd|j\}}}||ddS)NrArBr-ddinsdaleFile "dinsdale)rrrr rur5rrrrrrtest_d_compile_errorsz)CommandLineTestsBase.test_d_compile_errorcCst|jdd}|ddd|jt|jdd}tj|}t|tj |jdt |tj |d d \}}}| |d dS) Nrzraise ExceptionrrHrIbingz import bazzbaz.pycF) __isolatedrJ)rrrr r rrrrenamer(r)removerru)r5rrpr"rrrrrrtest_d_runtime_errors  z)CommandLineTestsBase.test_d_runtime_errorcCsZ|dtj|jd|j\}}}||d||d|tj t j |j dS)N-i nosuchfilesrror.*nosuchfiles Traceback)r rr(r)r'rruZassertNotRegexrorr rrrrKrrrtest_include_bad_files   z*CommandLineTestsBase.test_include_bad_filecCst|jdd}t|jdd}t|jdd}t|jdd}ttj|jddH}|tj|jdtj |tj|jd tj Wdn1s0Y| d tj|jd|| || || || |dS) Nf1r f2f3f4l1r$f1.pyf2.pyrR) rrrr,rr(r)r'r-linesepr rrr5rUrVrWrXrYrrrtest_include_file_with_args:   z/CommandLineTestsBase.test_include_file_with_argcCst|jdd}t|jdd}t|jdd}t|jdd}ttj|jdd,}|tj|jdtj Wdn1s0Y| d tj|jd| || || || |dS) NrUr rVrWrXrYr$r[rR) rrrr,rr(r)r'r-r\r rrr]rrrtest_include_file_no_args:   z-CommandLineTestsBase.test_include_file_no_argcCst|jdd}t|jdd}t|jdd}t|jdd}tj|dddg}|j|tj d t || || || || |dS) NrUr rVrWrXrrR-r) rrrZ spawn_pythonrstdinr-rr\encodeZ kill_pythonrr)r5rUrVrWrXprrrtest_include_on_stdins    z*CommandLineTestsBase.test_include_on_stdincCs\t|jdd}|d|j||j\}}}||d||||j||jdS)NrMz syntax(errorrSsrror) rrrr rrrurr)r5Zbingfnrrrrrr!test_compiles_as_much_as_possibles     z6CommandLineTestsBase.test_compiles_as_much_as_possiblecCs|d}||ddS)NZ badfilenamesCan't list 'badfilename')r ru)r5rrrr!test_invalid_arg_produces_messages z6CommandLineTestsBase.test_invalid_arg_produces_messagecCst|jddtjtj|jd}| d|jt |d}| }Wdn1s^0Y| t |dddd | d |jt |d}| }Wdn1s0Y| t |dddd dS) NrUr rZz --invalidation-mode=checked-hashr>littlerz"--invalidation-mode=unchecked-hashr)rrrr rrrr(r)r r,rBrdrC from_bytes)r5r"fprHrrrtest_pyc_invalidation_modes & &z/CommandLineTestsBase.test_pyc_invalidation_modezrequires multiprocessingcCst|jdd}g}tdD]F}tj|jd|}t|t|dd}| t|ddq| |jdd| ||D]}| |qdS)NrEr rzfoo{}rz-j0) rrr'rrr(r)r$r2rr r)r5rFfilessuffixrrpr6rrr test_workerss   z!CommandLineTestsBase.test_workerszcompileall.compile_dircCsftjdtj|jdgd:t||j| |j dddWdn1sX0YdS)Nzsys.argvz-j0rrrr) rrr executabler'rTmainrSrrdr)r5rgrrrtest_workers_available_cores$s   z1CommandLineTestsBase.test_workers_available_coresc Csgd}tjj|jg|R}t|t|dd}tj |}tjj|jg|ddR}d}| d|d||t |\}}} tjj|g|ddR} | | t | td||t | tddS) Nrr~rrrz-sz-pr)rr(r)r'rrrr rrr rrrrrrrrrrr,s$  z+CommandLineTestsBase.test_strip_and_prependc Cstj|jd}t|t|dd}g}dD]}|tj j ||dq0ddgddgddggd g}|D]j}|j |gd d |DR|D]D}| tj |t|zt||WqtyYq0qqldS) NZ optimizationsrrrr rm12)rmrtrucss|]}dt|VqdS)z-oN)r)rnrrrr*OrzICommandLineTestsBase.test_multiple_optimization_levels..)rr(r)r'rrrrr rrr rSrnrCrmr)r5r(rrirrrrrrr@s0    z6CommandLineTestsBase.test_multiple_optimization_levelsc Cstj|jddd}tj|jddd}tj|jddd}t|t|t|t|dd}t|dd}tj|d }tj|d }t||t||tj |}tj |} | |d || tj ||tj | dS) Nr~rrrrrrrrrz-e)rr(r)r'rrrrr rrr rSrnrorrrrrWs"       z4CommandLineTestsBase.test_ignore_symlink_destinationcCs||jdddS)N-o 1--hardlink-dupes)r r'r:rrrtest_hardlink_bad_argspsz+CommandLineTestsBase.test_hardlink_bad_argsc CsdD]}t}|j|dt|dd}t|}gd}|rL|d|j|g|R|t |d|d||t |d|d ||t |d|d |Wdn1s0YWdq1s0YqdS) N)TFdeduprr)rz-o 0rwz-o 2rxrrr) r%TemporaryDirectorysubTestrrrrr rdr!)r5r{r(rpycsrrrr test_hardlinkus  z"CommandLineTestsBase.test_hardlinkN)5rrr classmethodrrrr r rrr7rrrr!namer)r.r0localsr2r3r4r:r=rrr?r@rCrDrGrLrQrTr^r_rdrerfrlr_have_multiprocessingrprrrsrrrryrrrrrrsd            "          rc@s eZdZdS)CommandLineTestsWithSourceEpochNrrrrrrsrc@s eZdZdS)CommandLineTestsNoSourceEpochNrrrrrrsrc@seZdZddZejddZd#ddZdd d d d d ZddZ d$ddZ ddZ ddZ d%ddZ ddZddZddZddZd d!Zd"S)&HardlinkDedupTestsBasecCs d|_dSrr{r:rrrr7szHardlinkDedupTestsBase.setUpccs>t"}||_|Vd|_Wdn1s00YdSr)r%r|r()r5r(rrrtemporary_directorys z*HardlinkDedupTestsBase.temporary_directoryrcCst|j||Sr)rrr()r5coderrrrrsz"HardlinkDedupTestsBase.make_scriptTrF)r{rr\cCstj|jd|||ddS)NT)r]rhardlink_dupesr\)rTrgr()r5r{rr\rrrrgs z"HardlinkDedupTestsBase.compile_dirc Cs||d|t$tj|jddddWdn1sH0Y|t(tj|jdddgddWdn1s0YWdn1s0YdS)NpassTr)r]rr)rrrrrTrgr(r:rrr test_bad_argss    $ z$HardlinkDedupTestsBase.test_bad_argscCs4g}|r|d|d|r*|dd|S)Nz'module docstring'zx = 1z assert x == 1 )rr))r5 docstring assertionlinesrrr create_codes   z"HardlinkDedupTestsBase.create_codeccs2dD](}dD]}|j||d}|||fVq qdS)N)FTrr)r)r5rrrrrr iter_codessz!HardlinkDedupTestsBase.iter_codesc Cs|D]\}}}|j||d|v||}t|}|jdd|t|d|d|t|d|d|t|d|dWdn1s0YWdq1s0YqdS)NrFrzrrr)rr}rrrrgror!)r5rrrrr~rrr test_disableds   z$HardlinkDedupTestsBase.test_disabledcCsft|}|t|d|d| |t|d|d| oB| |t|d|d| dS)Nrrr)rrdr!)r5rrrr~rrrcheck_hardlinkss z&HardlinkDedupTestsBase.check_hardlinksc Cs|D]\}}}|j||dX|0||}|||||Wdn1s`0YWdq1s~0YqdS)Nr)rr}rrrgr)r5rrrrrrrrs   z$HardlinkDedupTestsBase.test_hardlinkc CsdD]}|j|d~|V||}|j|dt||d}t||d}|t||Wdn1sz0YWdq1s0YqdS)N))rr)rr)rr)optsrrr)r}rrrrgrrSr!)r5rrpyc1pyc2rrrtest_only_two_levelss  z+HardlinkDedupTestsBase.test_only_two_levelscCsn|R||}|jgddt|d}t|d}|t||Wdn1s`0YdS)N)rrrrrrr)rrrrgrrSr!)r5rrrrrrtest_duplicated_levelss    z-HardlinkDedupTestsBase.test_duplicated_levelscCs||d}|||t|}t|dj}|d}|jddgdd||t|dj| t |d|d| |t|dj| t j|d|dddWdn1s0YdS) Nrrprint(0)rT)rr\rshallow)rrrgrrrrrrdrSr!rfrofilecmpcmpr5rr~inoderrrtest_recompilations    z)HardlinkDedupTestsBase.test_recompilationcCs||j|dd}|||t|}t|dj}|jddd}t j dddd|j d | |t|dj| |t|d j| t|d |d | tj|d |d d d Wdn1s0YdS)Nmodule)rrrr#z-cz import moduleF)rNrrrTr)rrrrgrrrrrrr r(rdror!rrrrrr test_imports   z"HardlinkDedupTestsBase.test_importN)r)FF)FF)rrrr7rOcontextmanagerrrrgrrrrrrrrrrrrrrrs       rc@s eZdZdS)!HardlinkDedupTestsWithSourceEpochNrrrrrr7src@s eZdZdS)HardlinkDedupTestsNoSourceEpochNrrrrrr>sr__main__).rTrOrimportlib.utilr rQ itertoolsrrsrbr0rErr%Ztest.test_importlib.utilr~rr`rrconcurrent.futuresrr ImportErrorrZ test.supportrZtest_py_compilerr rrr!r"ZTestCaserrrrrrrrrrrrrrrrs       n  K