
    F-Ph                    l   d Z ddlmZ ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
l
mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e	rddlmZ d3dZd4dZ G d de          Z G d d          Z G d d          Zd5d"Zd6d%Z ed&d&'          d7d+            Z d6d,Z!d8d2Z"dS )9zBSupport for presenting detailed information in failing assertions.    )annotations)	GeneratorN)Any)Protocol)TYPE_CHECKING)rewrite)truncate)util)assertstate_key)Config)hookimpl)Parser)Item)Sessionparserr   returnNonec           	     <   |                      d          }|                    ddddddd	           |                     d
ddd           |                     dd d           |                     dd d           t          j        | t          j        d           d S )Ndebugconfigz--assertstore
assertmode)r   plainr   MODEzControl assertion debugging tools.
'plain' performs no assertion debugging.
'rewrite' (the default) rewrites assert statements in test modules on import to provide assert expression information.)actiondestchoicesdefaultmetavarhelpenable_assertion_pass_hookboolFzeEnables the pytest_assertion_pass hook. Make sure to delete any previously generated pyc cache files.)typer   r   truncation_limit_linesz>Set threshold of LINES after which truncation will take effect)r   r   truncation_limit_charsz>Set threshold of CHARS after which truncation will take effectzSpecify a verbosity level for assertions, overriding the main level. Higher levels will provide more detailed explanation when an assertion fails.)r   )getgroup	addoptionaddinir   _add_verbosity_iniVERBOSITY_ASSERTIONS)r   groups     Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/_pytest/assertion/__init__.pypytest_addoptionr,      s    OOM**E	OO$C     MM$H	     MM M    
 MM N     #\	         namesstrc                 &   | D ]H}t          |t                    s1d}t          |                    t	          |                               It
          j        D ] }t          |t          j                  r|} n!t                      } |j
        |   dS )a  Register 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)
isinstancer/   	TypeErrorformatreprsys	meta_pathr   AssertionRewritingHookDummyRewriteHookmark_rewrite)r.   namemsghookrewrite_hooks        r+   register_assert_rewriter>   G   s      5 5$$$ 	5CCCJJtE{{33444	5  * *dG:;; 	LE	 ())Lu%%%%r-   c                      e Zd ZddZdS )RewriteHookr.   r/   r   r   c                    d S N selfr.   s     r+   r9   zRewriteHook.mark_rewritea   s      r-   Nr.   r/   r   r   )__name__
__module____qualname__r9   rC   r-   r+   r@   r@   `   s        444444r-   r@   c                      e Zd ZdZddZdS )	r8   z3A no-op import hook for when rewriting is disabled.r.   r/   r   r   c                    d S rB   rC   rD   s     r+   r9   zDummyRewriteHook.mark_rewriteg   s    r-   NrF   )rG   rH   rI   __doc__r9   rC   r-   r+   r8   r8   d   s.        ==     r-   r8   c                      e Zd ZdZddZdS )	AssertionStatezState for the assertion plugin.configr   r   r   c                j    || _         |j        j                            d          | _        d | _        d S )N	assertion)modetracerootgetr<   )rE   rO   rR   s      r+   __init__zAssertionState.__init__n   s.    	\&**;77
;?			r-   N)rO   r   r   r   )rG   rH   rI   rL   rV   rC   r-   r+   rN   rN   k   s4        ))@ @ @ @ @ @r-   rN   rO   r   rewrite.AssertionRewritingHookc                X    t           d           j        t          <   t          j                   x j        t                   _        }t          j                            d|            j        t                   	                    d           d fd} 
                    |           |S )z?Try to install the rewrite hook, raise SystemError if it fails.r   r   zinstalled rewrite import hookr   r   c                     j         t                   j        } | /| t          j        v r#t          j                            |            d S d S d S rB   )stashr   r<   r5   r6   remove)r<   rO   s    r+   undoz install_importhook.<locals>.undo{   sN    |O,1 5 5M  &&&&&  5 5r-   )r   r   )rN   rZ   r   r   r7   r<   r5   r6   insertrS   add_cleanup)rO   r<   r\   s   `  r+   install_importhookr_   t   s    $269$E$EFL!070Nv0V0VVFL!&MD!!!
L!''(GHHH' ' ' ' ' '
 tKr-   sessionr   c                    | j         j                            t          d           }|r#|j        |j                            |            d S d S d S rB   rO   rZ   rU   r   r<   set_sessionr`   assertstates     r+   pytest_collectionrf      s\     .&**?DAAK 2'((111112 2''r-   T)wrappertryfirstitemr   Generator[None, object, object]c              #     K    j         d fd}t          j        t          j        f}|t          _         j        t          _        j                                        rd fd}|t          _        	 dV |\  t          _        t          _        dt          _        S # |\  t          _        t          _        dt          _        w xY w)a  Setup 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.
    leftobjectrightr   
str | Nonec                .                        j        | ||          }|D ]r}|rnt          j        |          }d |D             }d                    |          }j                            d          dk    r|                    dd          }|c S sdS )	aJ  Call 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.
        rO   oprl   rn   c                :    g | ]}|                     d d          S )
z\n)replace).0lines     r+   
<listcomp>z@pytest_runtest_protocol.<locals>.callbinrepr.<locals>.<listcomp>   s&    KKK$DLLu55KKKr-   z
~r   r   %z%%N)pytest_assertrepr_comparerO   r	   truncate_if_requiredjoingetvalueru   )rr   rl   rn   hook_resultnew_explresihookri   s         r+   callbinreprz,pytest_runtest_protocol.<locals>.callbinrepr   s     55;2D 6 
 
 $ 	 	H #84HHKK(KKKjj**;''55BB++c400C


 tr-   linenointorigr/   explr   c                :                         | ||           d S )N)ri   r   r   r   )pytest_assertion_pass)r   r   r   r   ri   s      r+   call_assertion_pass_hookz9pytest_runtest_protocol.<locals>.call_assertion_pass_hook   s'    ''T&tRV'WWWWWr-   N)rl   rm   rn   rm   r   ro   )r   r   r   r/   r   r/   r   r   )r   r
   _reprcompare_assertion_passrO   _configr   get_hookimpls)ri   r   saved_assert_hooksr   r   s   `   @r+   pytest_runtest_protocolr      s       JE      8 *D,@@#D;DL"0022 8	X 	X 	X 	X 	X 	X 	X  82D/4/ 3E/4/s   5B 'Cc                    | j         j                            t          d           }|r#|j        |j                            d            d S d S d S rB   rb   rd   s     r+   pytest_sessionfinishr      sZ    .&**?DAAK /'((...../ /''r-   rr   rl   r   rn   list[str] | Nonec                2    t          j        | |||          S )Nrq   )r
   assertrepr_comparerq   s       r+   rz   rz      s     "&Rd%PPPPr-   )r   r   r   r   rF   )rO   r   r   rW   )r`   r   r   r   )ri   r   r   rj   )
rO   r   rr   r/   rl   r   rn   r   r   r   )#rL   
__future__r   collections.abcr   r5   typingr   r   r   _pytest.assertionr   r	   r
   _pytest.assertion.rewriter   _pytest.configr   r   _pytest.config.argparsingr   _pytest.nodesr   _pytest.mainr   r,   r>   r@   r8   rN   r_   rf   r   r   rz   rC   r-   r+   <module>r      sV   H H " " " " " " % % % % % % 



                         % % % % % % & & & & & & " " " " " " 5 5 5 5 5 5 ! ! ! ! ! ! # # # # # # , , , , , ,        %$$$$$$* * * *Z& & & &25 5 5 5 5( 5 5 5       @ @ @ @ @ @ @ @    2 2 2 2 
$&&&4 4 4 '&4n/ / / /Q Q Q Q Q Qr-   