bg: dZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZdd lmZddlmZddlmZerddlmZdeddfdZdeddfdZGddZGddZdede jfdZd)dZedd d!eded"fd#Zd)d$Z ded%ed&ed'edeeef d(Z!dS)*zBSupport for presenting detailed information in failing assertions.N)Any) Generator)List)Optional) TYPE_CHECKING)rewrite)truncate)util)assertstate_key)Config)hookimpl)Parser)Item)Sessionparserreturnc |d}|ddddddd |d d d d dS)N debugconfigz--assertstore assertmode)rplainrMODEzControl assertion debugging tools. 'plain' performs no assertion debugging. 'rewrite' (the default) rewrites assert statements in test modules on import to provide assert expression information.)actiondestchoicesdefaultmetavarhelpenable_assertion_pass_hookboolFzeEnables the pytest_assertion_pass hook. Make sure to delete any previously generated pyc cache files.)typerr)getgroup addoptionaddini)rgroups k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/assertion/__init__.pypytest_addoptionr's| OOM * *E OO $ C    MM$ H namesc&|D]H}t|ts1d}t|t |It jD] }t|tjr|}n!t}|j |dS)aRegister one or more module names to be rewritten on import. This function will make sure that this module or all modules inside the package will get their assert statements rewritten. Thus you should make sure to call this before the module is actually imported, usually in your __init__.py if you are a plugin using a package. :param names: The module names to register. z/expected module names as *args, got {0} insteadN) isinstancestr TypeErrorformatreprsys meta_pathrAssertionRewritingHookDummyRewriteHook mark_rewrite)r)namemsghook importhooks r&register_assert_rewriter9/s55$$$ 5CCCJJtE{{3344 4 5 (( dG: ; ; J E  &'' JU####r(c"eZdZdZdeddfdZdS)r3z3A no-op import hook for when rewriting is disabled.r)rNcdSN)selfr)s r&r4zDummyRewriteHook.mark_rewriteLs r()__name__ __module__ __qualname____doc__r,r4r=r(r&r3r3Is<== 3 4      r(r3c"eZdZdZdeddfdZdS)AssertionStatezState for the assertion plugin.configrNcj||_|jjd|_d|_dS)N assertion)modetracerootgetr7)r>rErHs r&__init__zAssertionState.__init__Ss. \&**;77 >B r()r?r@rArBr rLr=r(r&rDrDPsD))CvCCCCCCCr(rDrEcXtdjt<tjxjt_}t jd|jt ddfd } ||S)z?Try to install the rewrite hook, raise SystemError if it fails.rrzinstalled rewrite import hookrNcjtj}|/|tjvr#tj|dSdSdSr<)stashr r7r0r1remove)r7rEs r&undoz install_importhook..undo`sN|O,1   5 5 M  & & & & &   5 5r()rN) rDrOr rr2r7r0r1insertrI add_cleanup)rEr7rQs` r&install_importhookrTYs$269$E$EFL!070Nv0V0VVFL!&MD!!! L!''(GHHH''''''  t Kr(sessionrc|jjtd}|r#|j|j|dSdSdSr<rErOrKr r7 set_sessionrU assertstates r&pytest_collectionr[is\.&**?DAAK2   '   ( ( 1 1 1 1 122 ' 'r(T)tryfirst hookwrapperitem)NNNc#Kjdtdtdttffd }tjtjf}|t_jt_j r*dtdtdtddffd }|t_dV|\t_t_dt_dS) aSetup the pytest_assertrepr_compare and pytest_assertion_pass hooks. The rewrite module will use util._reprcompare if it exists to use custom reporting via the pytest_assertrepr_compare hook. This sets up this custom comparison for the test. leftrightrc.j|||}|D]r}|rntj|}d|D}d|}jddkr|dd}|cSsdS) aJCall the pytest_assertrepr_compare hook and prepare the result. This uses the first result from the hook and then ensures the following: * Overly verbose explanations are truncated unless configured otherwise (eg. if running in verbose mode). * Embedded newlines are escaped to help util.format_explanation() later. * If the rewrite mode is used embedded %-characters are replaced to protect later % formatting. The result can be formatted by util.format_explanation() for pretty printing. rEopr`rac:g|]}|ddS) z\n)replace).0lines r& z@pytest_runtest_protocol..callbinrepr..s&KKK$DLLu55KKKr(z ~rr%z%%N)pytest_assertrepr_comparerEr truncate_if_requiredjoingetvaluerg)rdr`ra hook_resultnew_explresihookr^s r& callbinreprz,pytest_runtest_protocol..callbinrepr~s55;2D6  $  H #84HHKK(KKKjj**;'' 55BB++c400C  tr(linenoorigexplNc:|||dS)N)r^rurvrw)pytest_assertion_pass)rurvrwrsr^s r&call_assertion_pass_hookz9pytest_runtest_protocol..call_assertion_pass_hooks'  ' 'T&tRV ' W W W W Wr() rsobjectrr,r _reprcompare_assertion_passrE_configry get_hookimplsint)r^rtsaved_assert_hooksrzrss` @r&pytest_runtest_protocolrss JEfV 8*D,@@#D;DL "00228 XS X X3 X4 X X X X X X X 8 EEE.@+Dt+DLLLr(c|jjtd}|r#|j|jddSdSdSr<rWrYs r&pytest_sessionfinishrsZ.&**?DAAK/   '   ( ( . . . . .// ' 'r(rdr`rac2tj||||S)Nrc)r assertrepr_comparercs r&rlrls  "&Rd% P P PPr()rUrrN)"rBr0typingrrrrr_pytest.assertionrr r _pytest.assertion.rewriter _pytest.configr r _pytest.config.argparsingr _pytest.nodesr _pytest.mainrr'r,r9r3rDr2rTr[rrrlr=r(r&rsHH  %%%%%%&&&&&&""""""555555!!!!!!######,,,,,,%$$$$$$V2$C$D$$$$4        CCCCCCCC v '*H     2222 4T***4$495E+F444+*4n////Q QQ#&Q/2Q d3iQQQQQQr(