a 4êdg/ã@srddlZddlZddlZddlmZeedƒr8eedƒsBe d¡‚e d¡ZGdd„dej ƒZ e d krne  ¡dS) éN)ÚsupportÚ addaudithookÚauditz.test only relevant when sys.audit is availablezaudit-tests.pyc@s„eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS) Ú AuditTestcGs‚tjtjdtg|¢dtjtjdL}| ¡tj |j¡tj  |j ¡|j r`|  d  |j ¡¡Wdƒn1st0YdS)Nú-X utf8úutf-8©ÚencodingÚstdoutÚstderrÚ) Ú subprocessÚPopenÚsysÚ executableÚAUDIT_TESTS_PYÚPIPEÚwaitr Ú writelinesr Ú returncodeÚfailÚjoin)ÚselfÚargsÚp©rú+/usr/local/lib/python3.9/test/test_audit.pyÚdo_testsüzAuditTest.do_testcGs€g}tjtjdtg|¢dtjtjdF}| ¡tj |j¡|j dd„|j Dƒd  |j¡fWdƒS1sr0YdS)NrrrcSsg|]}| ¡ d¡‘qS)ú )ÚstripÚ partition)Ú.0ÚlinerrrÚ )óz(AuditTest.run_python..r ) r rrrrrrr rrr r)rrÚeventsrrrrÚ run_pythonsü ýzAuditTest.run_pythoncCs| d¡dS)NÚ test_basic©r©rrrrr'-szAuditTest.test_basiccCs| d¡dS)NÚtest_block_add_hookr(r)rrrr*0szAuditTest.test_block_add_hookcCs| d¡dS)NÚ!test_block_add_hook_baseexceptionr(r)rrrr+3sz+AuditTest.test_block_add_hook_baseexceptioncCst d¡| d¡dS)NÚpickleÚ test_pickle)rÚ import_modulerr)rrrr-6s zAuditTest.test_picklecCs| d¡dS)NÚtest_monkeypatchr(r)rrrr/;szAuditTest.test_monkeypatchcCs| dtj¡dS)NÚ test_open)rrZTESTFNr)rrrr0>szAuditTest.test_opencCs| d¡dS)NÚ test_cantracer(r)rrrr1AszAuditTest.test_cantracecCs| d¡dS)NÚ test_mmapr(r)rrrr2DszAuditTest.test_mmapcCs6| d¡\}}}|s$| d|›¡| dg|¡dS)NÚtest_excepthookzExpected fatal exception )zsys.excepthookrzRuntimeError('fatal-error'))r&rÚassertSequenceEqual©rrr%r rrrr3Gs ÿzAuditTest.test_excepthookcCsJ| d¡\}}}|r| |¡| |ddd¡| |ddd¡dS)NÚtest_unraisablehookrzsys.unraisablehookézDRuntimeError('nonfatal-error') Exception ignored for audit hook test)r&rÚ assertEqualr5rrrr6Ps  þzAuditTest.test_unraisablehookcCs¸t d¡| d¡\}}}|r(| |¡| |ddd¡| |ddd¡|dd}| |¡| dd |›d g|d¡| dd |›d g|d ¡| d d |g|d¡dS)NÚwinregÚ test_winregrzwinreg.OpenKeyézwinreg.OpenKey/resultr7zwinreg.EnumKeyrz 0z 10000ézwinreg.PyHKEY.Detaché)rr.r&rr8Ú assertTruer4)rrr%r Zexpectedrrrr:[s    zAuditTest.test_winregcCs”t d¡| d¡\}}}|r(| |¡tjrÚendswithr5rrrr@is  zAuditTest.test_socketcCsP| d¡\}}}|r| |¡tjr2t|ddiŽ| dd„|Dƒgd¢¡dS)NÚtest_gcrArBcSsg|] }|d‘qS)rr)r!Úeventrrrr#~r$z%AuditTest.test_gc..)zgc.get_objectszgc.get_referrerszgc.get_referents)r&rrrCrDr8r5rrrrFvs  þzAuditTest.test_gcN)Ú__name__Ú __module__Ú __qualname__rr&r'r*r+r-r/r0r1r2r3r6r:r@rFrrrrrs    rÚ__main__) r rZunittestÚtestrÚhasattrZSkipTestZfindfilerZTestCaserrHÚmainrrrrÚs   t