j7iZddlmZddlmZddlmZddlmZddlmZddlZddlm Z ddl Z ddl m Z ddl Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl$m&Z&ddl'm(Z(ddl'm)Z)e jTd krdd!l+m,Z,er dd"l-m.Z.dd#l/m0Z0d$Z1Gd%d&Z2 d4d'Z3 d5d(Z4 d6d)Z5Gd*d+e2Z6eGd,d-e2Z7Gd.d/eZ8 d7d0Z9 d8d1Z:d9d2Z;d:d3Z!22A!67$=$D$D dGQ}%sAlO%   s AA! A!cPeZdZUded<ded<ded<ded<d ed <d ed <dd Zerd dZd!dZd"dZe d#dZ e d#dZ e d#dZ e d#dZ e d$dZe d$dZe d$dZe d#dZe d$dZe d%dZ d&dZd'dZed(dZy)) BaseReport str | Nonewhen"tuple[str, int | None, str] | NonelocationONone | ExceptionInfo[BaseException] | tuple[str, int, str] | str | TerminalReprlongreprzlist[tuple[str, str]]sectionsstrnodeid&Literal['passed', 'failed', 'skipped']outcomec :|jj|yN)__dict__update)selfkws r5__init__zBaseReport.__init__Gs R cyrE)rHkeys r5 __getattr__zBaseReport.__getattr__LsrKcBt|dr(t|j}|r|j||j}|yt|dr"t t |}|j|y t|}|j|y#t$rd}YwxYw)Nr1 toterminalz) hasattrr6r1liner>r rrQr@UnicodeEncodeError)rHout worker_infor>longrepr_terminalr4s r5rQzBaseReport.toterminalNs 4 +DII6K%==    8\ * $\8 <   ( ( - -M HHQK& -, -s3 B BBc#dK|jD]\}}|j|s||fywrE)r? startswith)rHprefixnamecontents r5 get_sectionszBaseReport.get_sectionsbs3!]] &MD'v&go% &s$0 0ct}t|}d|_|j||j }|j S)zRead-only property that returns the full string representation of ``longrepr``. .. versionadded:: 3.0 F)rr hasmarkuprQgetvaluestrip)rHfiletwexcs r5 longreprtextzBaseReport.longreprtextgs?z D !  mmoyy{rKcPdjd|jdDS)z_Return captured log lines, if log capturing is enabled. .. versionadded:: 3.5  c3&K|] \}}| ywrErM.0rZr\s r5 z$BaseReport.caplog..{s )G z Captured logjoinr]rHs r5caplogzBaseReport.caplogus- yy -1->->~-N   rKcPdjd|jdDS)zbReturn captured text from stdout, if capturing is enabled. .. versionadded:: 3.0 c3&K|] \}}| ywrErMris r5rkz'BaseReport.capstdout.. )G rlzCaptured stdoutrmros r5 capstdoutzBaseReport.capstdout. ww -1->->?P-Q   rKcPdjd|jdDS)zbReturn captured text from stderr, if capturing is enabled. .. versionadded:: 3.0 rrc3&K|] \}}| ywrErMris r5rkz'BaseReport.capstderr..rtrlzCaptured stderrrmros r5 capstderrzBaseReport.capstderrrvrKc |jdk(S)zWhether the outcome is passed.passedrCros r5r{zBaseReport.passed||x''rKc |jdk(S)zWhether the outcome is failed.failedr|ros r5rzBaseReport.failedr}rKc |jdk(S)zWhether the outcome is skipped.skippedr|ros r5rzBaseReport.skippeds||y((rKc>|jjddS)z3The path portion of the reported node, as a string.z::r)rAsplitros r5fspathzBaseReport.fspaths{{  &q))rKcy)a6**Experimental** Whether this report should be counted towards the totals shown at the end of the test session: "1 passed, 1 failure, etc". .. note:: This function is considered **experimental**, so beware that it is subject to changes even in patch releases. TrMros r5count_towards_summaryz BaseReport.count_towards_summarysrKc@|j|j\}}}|Sy)a**Experimental** The head line shown with longrepr output for this report, more commonly during traceback representation during failures:: ________ Test.foo ________ In the example above, the head_line is "Test.foo". .. note:: This function is considered **experimental**, so beware that it is subject to changes even in patch releases. N)r<)rH_fspath_linenodomains r5 head_linezBaseReport.head_lines& == $'+}} $GWfMrKc|jj||\}}}t|tr||fSt|tr7t |dk(r)|\}}t|trt|t r||fStd|dy)N)reportconfigzSpytest_report_teststatus() hook (from a plugin) returned an invalid verbose value: z8. Expected either a string or a tuple of (word, markup).)hookpytest_report_teststatus isinstancer@rlenrr!)rHrdefault_markup _category_shortverbosewordmarkups r5_get_verbose_word_with_markupz(BaseReport._get_verbose_word_with_markups&,[[%I%I&J& " 67 gs #N* * gx (S\Q->"LD&$$FG)DV|#  ))0 4, , rKct|S)zReturn the contents of this report as a dict of builtin entries, suitable for serialization. This was originally the serialize_report() function from xdist (ca03269). Experimental method. )_report_to_jsonros r5_to_jsonzBaseReport._to_jsonst$$rKc(t|}|di|S)aCreate either a TestReport or CollectReport, depending on the calling class. It is the callers responsibility to know which class to pass here. This was originally the serialize_report() function from xdist (ca03269). Experimental method. rM)_report_kwargs_from_json)cls reportdictkwargss r5 _from_jsonzBaseReport._from_jsons**5}V}rKN)rIr returnNone)rNr@rr rUrrr)rZr@rzIterator[tuple[str, str]]rr@)rbool)rr9)rrrzMapping[str, bool]rztuple[str, Mapping[str, bool]])rdict[str, Any])rzdict[str, object]rr&)__name__ __module__ __qualname____annotations__rJrrOrQr]propertyrerpruryr{rrrrrrr classmethodrrMrKr5r8r8=s> 00W$# K 33!3(&         (((())**  (  .@ ' *%  rKr8cd}t}td|td||td||t||td||td|t|j)Nz+https://github.com/pytest-dev/pytest/issueszd----------------------------------------------------------------------------------------------------)streamz,INTERNALERROR: Unknown entry type returned: z report_name: zPlease report this bug at )rr RuntimeErrorr`) type_name report_classrurlrs r5_report_unserialization_failurersu 8C ZF 9V$ 9) EfU ]<. )&9 :f% 'u -f= 9V$ v( ))rKc|jdk(r|j|}|S|j||jj dd}|S)Ncalltbstyleauto)style)r: repr_failure_repr_failure_pyr getoption)itemrexcinfor>s r5_format_failed_longreprrs[ yyF$$W- O(( 4;;00FC)  OrKcH|j}|Jdtd|jjDr7|j dd\}}|Jt j ||dzf}d}n-t|j|jf}|j}g}|jjD]G}t|ddxs|jr|jdnd} | s2| |vs7|j| I|rdj|n|} g|| } | S) N=There should always be a traceback entry for skipping a test.c36K|]}t|ddyw)_use_item_locationFN)getattr)rjr"s r5rkz?_format_exception_group_all_skipped_longrepr..s 7;*E2 srrmsgrz; ) _getreprcrashallvalue exceptions reportinfoosrr@pathlinenomessagerargsappendrn) rrrrrSloc default_msgmsgs exceptionmreasonr>s r5,_format_exception_group_all_skipped_longreprrs+ A =G=  ?F}}?W?W __&r* dyyq) 166{AHH%ii D]]-- Iud + !*INN1 T  $ KKN !%TYYt_+F~f~H OrKc|eZdZUdZdZded< d d dZd dZed dZ y) TestReportzBasic test report object (also used for setup and teardown calls if they fail). Reports can contain arbitrary extra attributes. Fr@wasxfailNc  ||_||_||_||_||_||_t | xsg|_t ||_||_ | |_ | |_ |jj| yrE)rAr<keywordsrCr>r:listuser_propertiesr?durationstartstoprFrG) rHrAr<rrCr>r:r?rrrrextras r5rJzTestReport.__init__>s( 6> ,4  ! ;?  $O$9r: X  ( "   U#rKc d|jjd|jd|jd|jd S)N< z when= outcome=>) __class__rrAr:rCros r5__repr__zTestReport.__repr__|s?4>>**+1T[[O6$))iX\XdXdWgghiirKc n|j}|dk7sJ|j}|j}|j}|jDcic]}|d}}|j } g} |j sd} d} nat | tsd} | } nKt | jtjrd} | j} | Jd| jjr@|jdd\}}|Jtj||dz| j f} nt#| j$| j&| j f} nt | jt(r`| jj+tjd4d} t-tt(t.t(z| } t1|| } nd} t3||| } |j4D]\}}}| j7d |d ||f!||j8|j:|| | || ||||j< Scc}w) zCreate and fill a TestReport with standard item and call info. :param item: The item. :param call: The call info. collectrr{Nrrrrz Captured r)r)r:rrrrrrrrr" Exceptionrrrrrrr@rrr%rr BaseExceptionrr_report_sectionsrrAr<r)rrrr:rrrxrrr?rCr>rrrSrwhenrNr\s r5from_item_and_callzTestReport.from_item_and_calls'yyy   == yy"&--0QAqD00,,||>FG g}5""GMM4>>:#))+}S}==33!%!22A!6JD$+++ " $199EH #AFF QXXqyyAHGMM+=> ##DNN3A6>$!*=;M+MN  HgV"24wG#'#8#8 B E3 OOyQug6@ A B KK MM         00  [1s H2)rMrrrN)rAr@r<ztuple[str, int | None, str]rzMapping[str, Any]rCrBr>r=r:z$Literal['setup', 'call', 'teardown']r?Iterable[tuple[str, str]]rfloatrrrrrz#Iterable[tuple[str, object]] | Nonerrr)rr rCallInfo[None]rr) rrr__doc____test__rrJrrrrMrKr5rr1s HM/1?C!<$<$.<$$ <$ 8 <$  <$3<$,<$<$<$<$ =!<$$ %<$|jE E rKrcTeZdZdZdZ d ddZe d dZd dZy) CollectReportzSCollection report object. Reports can contain arbitrary extra attributes. rc ||_||_||_|xsg|_t ||_|j j|yrE)rArCr>resultrr?rFrG)rHrArCr>rr?rs r5rJzCollectReport.__init__sI  ! l X  U#rKc4|jd|jfSrE)rros r5r<zCollectReport.locations T4;;//rKchd|jdt|jd|jdS)Nzr=rzlist[Item | Collector] | Noner?rrr)rr;r) rrrrr:rJrr<rrMrKr5rrsu D/1$$8$ $.$,$ $B0 +00 hrKrceZdZddZddZy)CollectErrorReprc||_yrE)r>)rHrs r5rJzCollectErrorRepr.__init__s  rKc>|j|jdy)NT)red)rSr>)rHrUs r5rQzCollectErrorRepr.toterminals D)rKN)rr@rrr)rrrrJrQrMrKr5rrs *rKrct|ttzr+|j}|jj |d<|Sy)N $report_type)rrrrrr)rdatas r5pytest_report_to_serializabler s=&*}45 %//88^ rKcd|vrS|ddk(rtj|S|ddk(rtj|SJdj|dy)Nrrrz(Unknown report_type unserialize data: {})rrrr0)rs r5pytest_report_from_serializabler so  < /((. . . !_ 4 ++D1 1 @GG    u rKc d dd fd  d ddfd }|jj}t|jdrQt|jdr"t|jdr |||d<n(t |j|d<n|j|d<|D]F}t ||t jrt j||||<<|d k(sBd ||<H|S)zReturn the contents of this report as a dict of builtin entries, suitable for serialization. This was originally the serialize_report() function from xdist (ca03269). ctj|}|jD]*\}}t|dstj|||<,t |j |d}|S)NrF)typer) dataclassesasdictitemsrRrr)entryrrNr entry_datas r5serialize_repr_entryz-_report_to_json..serialize_repr_entry$sg!!%(**, 6JCuj)'..u5S  6#5k22DA rK reprtracebackctj|}|jDcgc] }| c}|d<|Scc}w)N reprentries)rrr)rrrrs r5serialize_repr_tracebackz1_report_to_json..serialize_repr_traceback.sE##M2-:-F-F! ()  #! } ! s< reprcrashc2|tj|SyrE)rr)rs r5serialize_repr_crashz-_report_to_json..serialize_repr_crash5s  %%i0 0rKc`|jJtt|j}|j|j|j d}t |tr?g|d<|jD])\}}}|dj|||f+|Sd|d<|S)N)rrr?chain) r>r rrrr?rrrr)repr>rrepr_traceback repr_crash descriptionrrs r5serialize_exception_longreprz5_report_to_json..serialize_exception_longrepr=s||''' s||4-h.@.@A5h6L6LM ))"  h 2 3 F7O;C>> 7 Kw&&0@,Z8#  #F7O rKrQr>rN)rzReprEntry | ReprEntryNativerr)rrrr)rzReprFileLocation | Nonerdict[str, Any] | None)rr8rr) rFcopyrRr>r@rrPathLiker)rr"r2r[rrrs @@@r5rrs* * . Av - 6??O 4 OO[: 9@AjM0AjM*  agr{{ +ii$(AdG X AdG  HrKcn fd fd}d d}drddvrddvr|dd}|dd}ddr?g}ddD]&\}}}|j|||||f(t|} n t||} dd D]} | j| | d<S) zReturn **kwargs that can be used to construct a TestReport or CollectReport instance. This was originally the serialize_report() function from xdist (ca03269). c&|d}|d}|dk(rZd}d}d}|drtd i|d}|drtd i|d}|drt|dd}t|d||||d }|S|d k(rt |d}|St |t S) Nrrr reprfuncargs reprfileloc reprlocalslinesr)r+r(r*r)rrrM)rrrrrrr)rr entry_typer(r)r* reprentryrs r5deserialize_repr_entryz8_report_kwargs_from_json..deserialize_repr_entryms&!'  $LKJN#+Cd>.BC M".Em1DE L!'\(:7(CD 5>7m)%'7m 6I , ,'W 6I ,J J OrKc\|dDcgc] }| c}|d<tdi|Scc}w)NrrMr)repr_traceback_dictrr.s r5deserialize_repr_tracebackz<_report_kwargs_from_json..deserialize_repr_tracebacks?/B=/Q. *+ "1 %. M*3233. s)c| tdi|Sy)NrMr)repr_crash_dicts r5deserialize_repr_crashz8_report_kwargs_from_json..deserialize_repr_crashs  &#6o6 6rKr>rrr)rrr?)r3r#)rrr addsection) rr1r4rrrrepr_traceback_datarepr_crash_datar!exception_infosectionr.s ` @r5rrfs$64  : :j1 1 z*5 52 z "? 3 +:j+A++NO j !' *EEOFF A#_k 23FG.?# FXFN/+#N "*-j9 0G %N % %w / 0!/ : rK)rr@rztype[BaseReport]rr)rr rrrzExceptionInfo[BaseException])rr rzEExceptionInfo[BaseExceptionGroup[BaseException | BaseExceptionGroup]]rztuple[str, int, str])rzCollectReport | TestReportrr#)rrrz!CollectReport | TestReport | None)rr8rr)rrrr)= __future__rcollections.abcrrrrriorrr systypingr r r r rr_pytest._code.coderrrrrrrrrrr _pytest._ior_pytest.configr _pytest.nodesrr _pytest.outcomesr!r"r)exceptiongroupr%typing_extensionsr&_pytest.runnerr'r6r8rrrrrrr r rrrMrKr5rGsc"$$#$   1,,(.0/+),+&!#!!g1&' uup * *"2 *  *   $ /K   RBT T n0hJ0h0hf*|* &   & F RPrK