f _&@sddlZddlZddlZddlZddlZddlZddlmZz ddlZWne y^dZYn0ddl m Z ddZ ddZ dS)N)support)setup_unraisable_hookc Cs ztj}Wnttfy(d}YnZ0tjd|dg}ttdrR| tj ttdrh| tj |D]}tj |d|dqlt ttj|jrtjdtj|jtjD]P}t|drt|jD]\}}tj||j|<qt|ddrtj|j|_q|jrd tj_|j dur6t!|j |j"durNt#$|j"t%|j&ob|j&d k|j't_'ttd rd d }t(|t)|j*durt+tj,|j*dt_,t+tj-|j*dt_-t.tj/|j*t_/t.tj0|j*t_0t.tj,|j*t_,t.tj-|j*t_-dS)NT)Z all_threadsfileSIGALRMSIGUSR1)chainrr__path____file__F addaudithookcSsdSN)nameargsr r //usr/lib64/python3.10/test/libregrtest/setup.py_test_audit_hookNsz%setup_tests.._test_audit_hook()1sys __stderr__fileno ValueErrorAttributeError faulthandlerenablehasattrsignalappendrrregisterreplace_stdoutrZrecord_original_stdoutstdoutZtestdirpathinsertosabspathmodulesvalues enumeratergetattrr Z huntrleaksunittestZ BaseTestSuite_cleanupmemlimitZ set_memlimitZ thresholdgcZ set_thresholdZsuppress_msvcrt_assertsverboseZ use_resourcesr rtimeoutmaxZ SHORT_TIMEOUTZ LONG_TIMEOUTminZLOOPBACK_TIMEOUTZINTERNET_TIMEOUT)nsZ stderr_fdZsignalssignummoduleindexr!rr r r setup_testssR                r5csZtjz }Wnty&YdS0t|djddddt_fdd}t|dS) zSet stdout encoder error handler to backslashreplace (as stderr error handler) to avoid UnicodeEncodeError when printing a tracebackNwbackslashreplaceF )encodingerrorsclosefdnewlinecstjt_dSr )rr closer r r rrestore_stdoutts z&replace_stdout..restore_stdout)rr rropenr9atexitr)fdr?r r>rr`s   r)rArr#rrr)testrr, ImportErrorZtest.libregrtest.utilsrr5rr r r rs     P