K i".ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZddlmZddlmZej(dZGddej,ZGd d ej,ZGd d ej,Zy) N)utf8) LogFormatterdefine_logging_optionsenable_pretty_logging) OptionParser)basestring_typec#Ktj5tjdtddddy#1swYyxYww)Nignore)category)warningscatch_warnings simplefilter BytesWarning[/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/test/log_test.pyignore_bytes_warningr s9  "h> sA  A A A A cfeZdZejdZdZdZdZdZ dZ dZ dZ d Z d Zy ) LogFormatterTestsD(?s)\[E [0-9]{6} [0-9]{2}:[0-9]{2}:[0-9]{2} log_test:[0-9]+\] (.*)cDtd|_tjdi|j_d|j_tj d|_d|j_tj|_ tjj|jd|_|j!|j|_|j"j%|j|jj'|j"y)NF)colorrzlog.out)r formatterloggingERROR_colors_normalLoggerlogger propagatetempfilemkdtemptempdirospathjoinfilename make_handlerhandler setFormatter addHandlerselfs rsetUpzLogFormatterTest.setUp.s%E2 #*--!:!)nn%78 % '')  T\\9= ((7  !!$..1 t||,rc|jjtj|jtj |j yN)r*closer%unlinkr(rmdirr$r-s rtearDownzLogFormatterTest.tearDown?s2  $--  rc0tj|dS)Nutf-8encoding)r FileHandler)r.r(s rr)zLogFormatterTest.make_handlerDs""8g>>rct|jd5}|jj}tj j |}|r|jdcdddStd|z#1swYyxYw)Nrbzoutput didn't match regex: %r) openr(readstriprLINE_REmatchgroup Exception)r.flinems r get_outputzLogFormatterTest.get_outputGsz $-- & H!668>>#D ((..t4Awwqz  H H  ?$ FGG  H HsAA?1A??Bcz|jjd|j|jdy)Nfoosfoo)r error assertEqualrHr-s rtest_basic_loggingz#LogFormatterTest.test_basic_loggingPs+ %  *F3rc t5|jjd|j|j t t ddddy#1swYyxYw)N)rr rKrLrHrreprr-s rtest_bytes_loggingz#LogFormatterTest.test_bytes_loggingTsS ! # E KK  g &   T__.T']0C D E E Es AA""A+c t5|jjdjdddt t t r*|j|jtdy|j|jtttdy#1swYxYwNé) rr rKencode issubclassbytesrrLrHrrPr-s rtest_utf8_loggingz"LogFormatterTest.test_utf8_loggingZs ! # 1 KK  hoo/ 0 1 e_ -   T__.X ?   T__.T$x.5I0J K 1 1s *B77Cc td#t$r|jjdYnwxYw|j}|j |d|j d|y)NrOzcaught exceptionsException.*\\xe9s\n)rDr exceptionrH assertRegex assertNotIn)r.outputs rtest_bytes_exception_loggingz-LogFormatterTest.test_bytes_exception_logginggsc 6G$ $ 6 KK ! !"4 5 6" !56 (s $44c|jjd|j|jt dyrS)r rKrLrHrr-s rtest_unicode_loggingz%LogFormatterTest.test_unicode_loggingss/ (# *DN;rN)__name__ __module__ __qualname__recompilerAr/r5r)rHrMrQrXr^r`rrrrr'sGbjjWG-" ?H4E L )  #~ t||,nn%TU % rc|tj} |dz|j_t |j|j |j dt|j j|j jd|j jdjtj|dz}|j dt|t|dd5}|j|jd ddd|j jD]"}|j|j$tj|dzD]}t!j"|t!j$|y#1swYxYw#|j jD]"}|j|j$tj|dzD]}t!j"|t!j$|wxYw) N /test_logrjr r=hellor /test_log*r7r8^\[E [^]]*\] hello$)r"r#rjlog_file_prefixrr rLlenhandlersrKflushglobr>r[r?r2r%r3r4r.tmpdir filenamesrEr*r(s r test_log_filez%EnablePrettyLoggingTest.test_log_files!!# +1K+?DLL ( !$,,t{{ K   QDKK$8$8 9 : KK  g & KK  # ) ) + &<"78I   QI /ilW5 C  +AB C ;;//    !IIf|&;< $ (# $ HHV  C C ;;//    !IIf|&;< $ (# $ HHV s%C)F7?!F+ F7+F40F77BH;c@tj} |dz|j_d|j_t |j|j |j jd|j jdjtj|dz}|jdt|t|dd 5}|j|jd ddd|j jD]"}|j|j!$tj|dzD]}t#j$|t#j&|y#1swYxYw#|j jD]"}|j|j!$tj|dzD]}t#j$|t#j&|wxYw) Nrmtimernrorrpr=r7r8rq)r"r#rjrrlog_rotate_moderr rKrtrurvrLrsr>r[r?r2r%r3r4rws r!test_log_file_with_timed_rotatingz9EnablePrettyLoggingTest.test_log_file_with_timed_rotatings!!# +1K+?DLL (+1DLL ( !$,,t{{ K KK  g & KK  # ) ) + &<"78I   QI /ilW5 C  +AB C ;;//    !IIf|&;< $ (# $ HHV  C C ;;//    !IIf|&;< $ (# $ HHV s%C F!!F F FFBHc d|j_d|j_|jtt |j|j |j jD]"}|j|j$y#|j jD]"}|j|j$wxYw)N some_path wrong_modern) rjrrr} assertRaises ValueErrorrr rtrur2)r.r*s rtest_wrong_rotate_mode_valuez4EnablePrettyLoggingTest.test_wrong_rotate_mode_values +6DLL (+7DLL (   % {{   ;;//    4;;//    s AB=C)rarbrcr/rzr~r __classcell__)rks@rrgrgxs&((  rrgcBeZdZdZd dZdZdZdZdZdZ d Z d Z y) LoggingOptionTestz?Test the ability to enable and disable Tornado's logging hooks.Nc8d}d}dj|||g}tjtjd|g|xsgztj tj }|j\}}|j|jdd|zd|vS) Nz7from tornado.options import options, parse_command_linez%import logging; logging.info("hello");z-c)stdoutstderrrzprocess failed: %rshello) r' subprocessPopensys executablePIPESTDOUT communicaterL returncode) r. statementargsIMPORTLOG_INFOprogramprocrrs r logs_presentzLoggingOptionTest.logs_presents K:((FIx89 ^^T7 +tzr :??$$  ))+ !-AF-JK6!!rcD|j|jdy)Npass assertFalserr-s r test_defaultzLoggingOptionTest.test_defaults **623rcD|j|jdy)Nparse_command_line() assertTruerr-s rtest_tornado_defaultz&LoggingOptionTest.test_tornado_defaults ))*@ABrcH|j|jddgy)Nrz--logging=nonerr-s rtest_disable_command_linez+LoggingOptionTest.test_disable_command_line" **+ADTCUVWrcH|j|jddgy)Nrz--logging=Nonerr-s r*test_disable_command_line_case_insensitivezAQ@R  rr1) rarbrc__doc__rrrrrrrrrrrrrs0I"$4CXX   rr) contextlibrvrr%rdrrr"unittestr tornado.escaper tornado.logrrrtornado.optionsr tornado.utilrcontextmanagerrTestCaserrgrrrrrs   SS((  N