'L i3|dZddlmZddlmZddlmZddlmZddlmZddl m Z ddl m Z dd l m Z dd l m Z dd lZdd lZdd lmZdd lmZddlmZdd lZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl%m'Z'ddl(m)Z)ddl(m*Z*ddl(m+Z+ddl,m-Z-ddl.m/Z/ddl.m0Z0dd l.m1Z1dd!l2m3Z3erdd"l4m5Z5dd1Z=e d?d2Z>ejnGd3d4Z?ejnGd5d6Z@d@d7ZAdAd8ZBe3eeCeDfZEdBd9ZFe d$: dCd;ZGy )Dz*Builtin plugin that adds subtests support.) annotations) defaultdict)Callable)Iterator)Mapping)AbstractContextManager)contextmanager) ExitStack) nullcontextN) TracebackType)Any) TYPE_CHECKING) ExceptionInfosaferepr)CaptureFixture) FDCapture) SysCapture)Config)hookimpl)Parser)check_ispytest)fixture) SubRequest) catching_logs)LogCaptureHandler) LoggingPlugin) TestReport)CallInfo)check_interactive_exception)get_reraise_exceptions)StashKey)SelfcPtj|tjdy)NzSpecify verbosity level for subtests. Higher levels will generate output for passed subtests. Failed subtests are always reported.)help)r_add_verbosity_iniVERBOSITY_SUBTESTS)parsers V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/_pytest/subtests.pypytest_addoptionr*.s" !! k T)frozenslotskw_onlyc@eZdZUdZded<ded<d dZed dZy) SubtestContextzJThe values passed to Subtests.test() that are included in the test report. str | NonemsgzMapping[str, Any]kwargsc,tj|SN) dataclassesasdict)selfs r)_to_jsonzSubtestContext._to_json@s!!$''r+c"||d|dS)Nr2r3r2r3)clsds r) _from_jsonzSubtestContext._from_jsonCsqx( 44r+Nreturndict[str, Any])r>rBrAr#)__name__ __module__ __qualname____doc____annotations__r9 classmethodr?r<r+r)r0r09s)T O (55r+r0F)initceZdZUded<eddZddZd fd Zed fd Z e d fd Z xZ S) SubtestReportr0contextcL|j\}}}|d|jS)N )location_sub_test_description)r8_domains r) head_linezSubtestReport.head_lineLs,}} 1f4557899r+cxg}|jj)|jd|jjd|jjrOdj d|jjj D}|jd|ddj |xsdS) N[]z, c3BK|]\}}|dt|yw)=Nr).0kvs r) z6SubtestReport._sub_test_description..Vs($)/!Q1#Qx{m$$s()rNz ())rLr2appendr3joinitems)r8parts params_descs r)rPz#SubtestReport._sub_test_descriptionQs <<   ' LL1T\\--.a0 1 <<  ))$37<<3F3F3L3L3N$K LL1[M+ ,xx/-/r+cnt|}|d=d|d<|jj|d<|S)NrL SubTestReport _report_type_subtest.context)superr9rL)r8data __class__s r)r9zSubtestReport._to_json\s>w! O.^#'<<#8#8#:   r+c`t||}tj|d|_|S)Nrg)rhr?r0rL)r= reportdictreportrjs r)r?zSubtestReport._from_jsoncs/#J/'22:>P3QR r+ct||j}||_|rf|jr'|j j d|jf|jr'|j j d|jf|rC|jjjx}r|j j d|f|S)NzCaptured stdout callzCaptured stderr callzCaptured log call) rhr?r9rLoutsectionsr_errhandlerstreamgetvalue)r= test_reportrLcaptured_output captured_logsresultlogrjs r)_newzSubtestReport._newis#K$8$8$:;  ""&&(>@S@S'TU""&&(>@S@S'TU ]%:%:%A%A%J%J%LLcL OO " "$7#= > r+)rAstrr@)rlrBrArK) rurrLr0rvzCaptured | NonerwzCapturedLogs | NonerAr#) rCrDrErGpropertyrSrPr9rHr?rz __classcell__)rjs@r)rKrKHs}  :: 0  )  +   r+rKSubtestsc|jjjjd}| |jnt }t |jj||dS)z Provides subtests functionality.capturemanagerT _ispytest)nodeconfig pluginmanager get_pluginglobal_and_fixture_disabledr r~ihook)requestcapmamsuspend_capture_ctxs r)subtestsrsY\\ . . 9 9:J KF.4.@**k GLL&&(;WPT UUr+cFeZdZdZdd ddZ d d dZy) r~z_Subtests fixture, enables declaring subtests inside test functions via the :meth:`test` method.FrcDt|||_||_||_yr5)r_ihook_suspend_capture_ctx_request)r8rrrrs r)__init__zSubtests.__init__s" y! $7! r+Nc t|j|||j|j|jjS)ad Context manager for subtests, capturing exceptions raised inside the subtest scope and reporting assertion failures and errors individually. Usage ----- .. code-block:: python def test(subtests): for i in range(5): with subtests.test("custom message", i=i): assert i % 2 == 0 :param msg: If given, the message will be shown in the test report in case of subtest failure. :param kwargs: Arbitrary values that are also added to the subtest report. )rrr)_SubTestContextManagerrrrr)r8r2r3s r)testz Subtests.tests;2& KK  MM $ 9 9==''   r+) rpluggy.HookRelayr*Callable[[], AbstractContextManager[None]]rrrboolrANoner5)r2r1r3r rAr)rCrDrErFrrr<r+r)r~r~sfi    H                 r+cneZdZUdZded<ded<ded<ded <d ed <d ed <ddZ ddZy)rz Context manager for subtests, capturing exceptions raised inside the subtest scope and handling them through the pytest machinery. rrr1r2rBr3rrrrrrcdd}tj|_tj|_d|_t |_|j jt|j|_ |j jt|j|_ y)NT) time_start perf_counter_precise_start _exc_infor _exit_stack enter_contextcapturing_outputr_captured_outputcapturing_logs_captured_logs)r8__tracebackhide__s r) __enter__z _SubTestContextManager.__enter__s iik "//1$; $ 0 0 > > T\\ *! #..<< 4<< ( r+c Bd}|tj|}nd}|jjt j }||j z }t j}tdd||j||dd} |jj|jj| } tj| t|j |j"|j$|j&} | j(rH|j*j,t.} | |jjj0xxdz cc<|j35|jj5| dddt7| | r2|jj9|jj| | |At;|t=|j*ry |jj>j@ry y#1swYxYw) NTcall)startstopdurationwhenr)itemrr;)rvrwrm)rrrmF)!rfrom_exceptionrcloserrrrrrpytest_runtest_makereportrrrKrzr0r2r3rrfailedrstashfailed_subtests_keynodeidrpytest_runtest_logreportr pytest_exception_interact isinstancer!session shouldfail) r8exc_typeexc_valexc_tbrexc_info precise_stoprr call_inform sub_reportfailed_subtestss r)__exit__z_SubTestContextManager.__exit__s !  $33G>+G+G+Q+Q,N #%^556$W- 7.*B*B C     sA4B6B; BB  Bc*eZdZUdZded<dZded<y)rr{rorqN)rCrDrErorGrqr<r+r)rrGsCMCMr+rceZdZUded<y)rrrrN)rCrDrErGr<r+r)rrMs r+rcDt|tr|jSyr5)rrKr9rs r)pytest_report_to_serializablerRs&-(  r+cV|jddk(rtj|Sy)Nrfre)getrKr?)ris r)pytest_report_from_serializablerXs' xx?2''-- r+c>td|jt<y)Ncy)Nrr<r<r+r)z"pytest_configure..dsr+)rrr)rs r)pytest_configurercs(3I(>FLL$%r+)tryfirstc2|jdk7ry|jtjdk(}t |t r|j }|j}t|dr|ry|dk(rd}d}d}ny||||fS|jr|d d |fS|jr|ryd |d d |fS|jr |ry|d d|fSy|jt|j}|jr"|dkDrd|_|dkDrdnd} d|d| |_y)Nrrwasxfail)rrrskippedxfailedySUBXFAILu SUBFAILEDz subtests SUBPASSED- SUBSKIPPEDrrsrz contains z failed subtest)r get_verbosityrr'rrKoutcomerPhasattrrpassedrrrrlongrepr) rmrquietr descriptioncategoryshortstatusfailed_subtests_countsuffixs r)pytest_report_teststatusrgsS {{f  !:!: ;q @E&-(..224 6: &!I%$#Uvh{m$<< < ==C9[M!:: :}}%&wi0#;-7PPP%"C:k])CCC !' -@ A&-- P ==2Q6%FN1A5S2F )*?)@PVxXFO r+)r(rrAr)rrrAr~)rrrAzIterator[Captured])rrrAzIterator[CapturedLogs | None])rmrrAzdict[str, Any] | None)rirBrAzSubtestReport | None)rrrAr)rmrrrrAz0tuple[str, str, str | Mapping[str, bool]] | None)HrF __future__r collectionsrcollections.abcrrr contextlibrr r r r6rtypesr typingr rpluggy _pytest._coder_pytest._io.safereprr_pytest.capturerrr_pytest.configrr_pytest.config.argparsingr_pytest.deprecatedr_pytest.fixturesrr_pytest.loggingrrr_pytest.reportsr_pytest.runnerrr r! _pytest.stashr"typing_extensionsr#r* dataclassr0rKrr~rrrrrrrr{intrrrr<r+r)rs0"#$$#-% "  ')*%&!#,-$')-)&#61"&d$= 5 5> 5E"4J4#4n V V0 0 f WWWt8  "  "    6h{38457? 43 3 3633r+