
    BhP                    $   U d 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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ZddlmZ ddlmZ ddlmZ ddlmZ dZded<   dZded<   dZ ded<    G d de      Z!d6d7dZ"d8dZ#d9dZ$d:dZ%d;dZ&d;dZ'd;d Z(d;d!Z)d<d"Z*d<d#Z+d<d$Z,d<d%Z-	 	 	 	 d=d&Z.	 d>	 	 	 	 	 	 	 	 	 d?d'Z/	 d@	 	 	 	 	 	 	 	 	 dAd(Z0	 d@	 	 	 	 	 	 	 	 	 dBd)Z1	 d@	 	 	 	 	 	 	 	 	 dCd*Z2	 d@	 	 	 	 	 	 	 	 	 dDd+Z3	 d@	 	 	 	 	 	 	 	 	 dEd,Z4	 d@	 	 	 	 	 	 	 	 	 dEd-Z5	 d@	 	 	 	 	 	 	 	 	 dEd.Z6	 d@	 	 	 	 	 	 	 	 	 dEd/Z7	 d@	 	 	 	 	 	 	 	 	 dEd0Z8	 	 	 	 	 	 	 	 	 	 dFd1Z9	 d@	 	 	 	 	 	 	 	 	 dGd2Z:	 	 	 	 	 	 	 	 	 	 dAd3Z;d@dHd4Z<dId5Z=y)Jz"Utilities for assertion debugging.    )annotationsN)Callable)Iterable)Mapping)Sequence)Set)Any)Literal)Protocol)	normalize)outcomes)PrettyPrinter)saferepr)saferepr_unlimited)Configz2Callable[[str, object, object], str | None] | None_reprcomparez&Callable[[int, str, str], None] | None_assertion_passzConfig | None_configc                      e Zd ZdddZy)_HighlightFuncc                     y)z'Apply highlighting to the given source.N )selfsourcelexers      a/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/_pytest/assertion/util.py__call__z_HighlightFunc.__call__*   s        Npythonr   strr   zLiteral['diff', 'python']returnr"   )__name__
__module____qualname__r   r   r   r   r   r   )   s    6r   r   c                    | S )zDummy highlighter that returns the text unprocessed.

    Needed for _notin_text, as the diff gets post-processed to only show the "+" part.
    r   )r   r   s     r   dummy_highlighterr(   .   s	    
 Mr   c                P    t        |       }t        |      }dj                  |      S )a  Format an explanation.

    Normally all embedded newlines are escaped, however there are
    three exceptions: \n{, \n} and \n~.  The first two are intended
    cover nested explanations, see function and attribute explanations
    for examples (.visit_Call(), visit_Attribute()).  The last one is
    for when one explanation needs to span multiple lines, e.g. when
    displaying diffs.
    
)_split_explanation_format_linesjoin)explanationlinesresults      r   format_explanationr1   6   s'     {+E5!F99Vr   c                    | xs dj                  d      }|d   g}|dd D ]-  }|r|d   dv r|j                  |       |dxx   d|z   z  cc<   / |S )	zReturn a list of individual lines in the explanation.

    This will return a list of lines split on '\n{', '\n}' and '\n~'.
    Any other newlines will be escaped and appear in the line as the
    literal '\n' characters.
     r*   r      N){}~>z\n)splitappend)r.   	raw_linesr/   valuess       r   r+   r+   E   sh     "))$/Iq\NEAB-fQi#77LL "I'I	  
 Lr   c                   t        | dd       }dg}dg}| dd D ]"  }|j                  d      ro|d   rd}nd}|j                  t        |             |dxx   dz  cc<   |j                  d       |j                  dd	t        |      dz
  z  z   |z   |dd z          |j                  d
      r4|j	                          |j	                          ||d   xx   |dd z  cc<   |d   dv sJ |dxx   dz  cc<   |j                  d      rt        |      nt        |      dz
  }|j                  d	|z  |dd z          % t        |      dk(  sJ |S )a  Format the individual lines.

    This will replace the '{', '}' and '~' characters of our mini formatting
    language with the proper 'where ...', 'and ...' and ' + ...' text, taking
    care of indentation along the way.

    Return a list of formatted lines.
    Nr4   r   r5   r9   zand   zwhere z +  r6   )r7   r8   r7   )list
startswithr;   lenpop)r/   r0   stackstackcntlinesindents          r   r,   r,   V   sM    %)_FCEsHab	??3|LLV%RLALOOAMM$Ua!881<tABxGH__S!IIKLLN59ab)7j((("INI#'??3#7SZSZ!^FMM$-$qr(23% & u:??Mr   c                p    t        | t        j                  j                        xr t        | t               S N)
isinstancecollectionsabcr   r"   xs    r   
issequencerP   y   s(    a112M:a;M7MMr   c                "    t        | t              S rJ   )rK   r"   rN   s    r   istextrR   }   s    ar   c                "    t        | t              S rJ   )rK   dictrN   s    r   isdictrU      s    ar   c                .    t        | t        t        f      S rJ   )rK   set	frozensetrN   s    r   issetrY      s    a#y)**r   c                D    t        | t              xr t        | dd       d uS )N_fields)rK   tuplegetattrobjs    r   isnamedtupler`      s"    c5!Ogc9d&C4&OOr   c                     t        | dd       d uS )N__dataclass_fields__r]   r^   s    r   	isdataclsrd      s    3.5TAAr   c                     t        | dd       d uS )N__attrs_attrs__rc   r^   s    r   isattrsrg      s    3)40<<r   c                P    	 t        |        t        |        S # t        $ r Y yw xY w)NF)iterrR   	Exceptionr^   s    r   
isiterablerk      s,    S	#; s    	%%c                    t        | j                  d      rTt        | j                  j                  d      r4| j                  j                  j                  }t	        |       rd|v S |dk(  S y)a  Check if an instance of an object contains the default eq

    First, we check if the object's __eq__ attribute has __code__,
    if so, we check the equally of the method code filename (__code__.co_filename)
    to the default one generated by the dataclass and attr module
    for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated"
    __code__co_filenamezattrs generated z<string>T)hasattr__eq__rm   rn   rg   )r_   code_filenames     r   has_default_eqrr      sZ     szz:&73::3F3F+V

++773<%66
**r   c                   | j                  t        j                        }t        |t              xr+ t        |t              xr t        d|      t        d|      k(  }|dkD  rt        ||      }t        ||      }n0dt        |      z
  dz
  dz  }t        |||      }t        |||      }| d| d| }	| j                         j                  }
d}	 |d	k(  rt        |||
|      }n|d
k(  r$t        |      rt        |      rt        |||      }n|dk(  rt        |      rt        |      rdg}n|dk(  r%t        |      rt        |      rt        |||
|      }n}|dk(  r%t        |      rmt        |      rbt!        |||
|      }nS|dk(  r%t        |      rCt        |      r8t#        |||
|      }n)|dk(  r$t        |      rt        |      rt%        |||
|      }|sy|d   dk7  rdg|}|	g|S # t&        j(                  $ r  t*        $ rA t,        j.                  j0                  j3                         j5                         }d| ddg}Y qw xY w)z<Return specialised explanations for some operators/operands.NFDr4   )	use_asciiA      )maxsizeru    Nz==znot inz!=Both sets are equalz>=z<=r8   <z<(pytest_assertion plugin: representation of details failed: .z+ Probably an object has a faulty __repr__.)r   r3   )get_verbosityr   VERBOSITY_ASSERTIONSrK   r"   r   r   rB   r   get_terminal_writer
_highlight_compare_eq_anyrR   _notin_textrY   _compare_gte_set_compare_lte_set_compare_gt_set_compare_lt_setr   Exitrj   _pytest_codeExceptionInfofrom_current_getreprcrash)configopleftrightru   verbose	left_repr
right_reprrx   summaryhighlighterr.   
repr_crashs                r   assertrepr_comparer      sQ    ""6#>#>?G
 	4 	>uc"	>eT"iu&==  {&tyA	'C

 c"g! T7iH	eW	J
1RD*.G,,.99KK
:)${GLK8^d|u)$w?4ZT{uU|454ZT{uU|.tUKQ4ZT{uU|.tUKQ3YT{uU|-dE;P3YT{uU|-dE;P 1~(K("k"" ==  
]]00==?MMO
J:,VWX9

s   DG, ,AI	I	c                   g }t        |       rt        |      rt        | |||      }|S ddlm} t	        | |      st	        ||      r2t	        | |      r| n|}t	        | |      r|n| }|j                  |      }nt        |       t        |      u r0t        |       st        |       st        |       rt        | |||      }nnt        |       rt        |      rt        | |||      }nIt        |       rt        |      rt        | |||      }n$t        |       rt        |      rt!        | |||      }t#        |       r*t#        |      rt%        | |||      }|j'                  |       |S )Nr   )
ApproxBase)rR   
_diff_text_pytest.python_apir   rK   _repr_comparetyperd   rg   r`   _compare_eq_clsrP   _compare_eq_sequencerY   _compare_eq_setrU   _compare_eq_dictrk   _compare_eq_iterableextend)	r   r   r   r   r.   r   approx_side
other_sideexpls	            r   r   r      s8    Kd|u uk7C: 7 	2dJ':eZ+H",T:">$EK",T:">DJ%33J?K$Z4;&dOwt}T0B *${GLK*U"3.tUKQK4[U5\)${GLKD\fUm*4WMKd
5 1'e['JDt$r   c                   ddl m} g }|dk  rd}t        t        t	        |       t	        |                  D ]  }| |   ||   k7  s n |dkD  r|dz  }d| dg}| |d } ||d }t	        |       t	        |      k(  rHt        t	        |             D ]  }| |    ||    k7  s n |dkD  r|dz  }|d| d	gz  }| d|  } |d|  }d
}| j                         s|j                         r.t        t        |             } t        t        |            }|dgz  }|j                   |dj                  d  ||j                  |      | j                  |            D              d      j                                |S )zReturn the explanation for the diff between text.

    Unless --verbose is used this will skip leading and trailing
    characters which are identical to keep the diff minimal.
    r   )ndiffr4   *   
   z	Skipping z5 identical leading characters in diff, use -v to showNz6 identical trailing characters in diff, use -v to showTz;Strings contain only whitespace, escaping them using repr()r*   c              3  >   K   | ]  }|j                  d         yw)r*   N)strip.0rF   s     r   	<genexpr>z_diff_text.<locals>.<genexpr>J  s!      XD 

4 Xs   diffr   )difflibr   rangeminrB   isspacereprr"   r   r-   
splitlines)r   r   r   r   r   r.   ikeependss           r   r   r     s    K{s3t9c%j12AAw%(" 3 r6GAA3STK 8D!"IEt9E
"3t9%8uaRy( & 2vRs #9 9   CaRycr
H||~CISZ UVV II !%"2"28"<dooh>WX  	
 *, r   c                p   |dk  rt               sdgS dd l}t               j                  |       j	                         }t               j                  |      j	                         }ddg}|j                   |dj                  d |j                  ||      D              d      j	                                |S )	Nr   zUse -v to get more diffr3   z
Full diff:r*   c              3  <   K   | ]  }|j                           y wrJ   )rstripr   s     r   r   z'_compare_eq_iterable.<locals>.<genexpr>g  s      LD Ls   r   r   )running_on_cir   r   pformatr   r   r-   r   )r   r   r   r   r   left_formattingright_formattingr.   s           r   r   r   T  s     !|MO)**#o--d3>>@O$..u5@@B|$K II #MM*:OL  	
 *, r   c                6   t        | t              xr t        |t              }g }t        |       }t        |      }t        t	        ||            D ]d  }| |   ||   k7  s|r| ||dz    }	|||dz    }
n
| |   }	||   }
|j                  d| d |t        |	             d |t        |
                     n |r|S ||z
  }|rW|dkD  rd}t        | |         }nd|z
  }d}t        ||         }|dk(  r|| d ||       gz  }|S || d	| d
 ||       gz  }|S )Nr4   z	At index z diff:  != r   LeftRightz contains one more item: z
 contains z more items, first extra item: )rK   bytesrB   r   r   r;   r   r   )r   r   r   r   comparing_bytesr.   len_left	len_rightr   
left_valueright_valuelen_diffdir_with_moreextras                 r   r   r   q  s    !u-J*UE2JOK4yHE
I3x+,7eAh "!a!e_
#AA.!!W
#AhA3 Z 012${4CT7U6VX + -.  )#Ha<"MT)_-E8|H#MU8_-Eq= /!:;u;M:NO K   /H:5TU`afUgThi K r   c                ~    g }|j                  t        d| ||             |j                  t        d|| |             |S )Nr   r   )r   _set_one_sided_diffr   r   r   r   r.   s        r   r   r     sC     K*64LM*7E4MNr   c                *    t        | ||      }|sdgS |S Nrz   )r   r   s        r   r   r     $     #4<K%&&r   c                *    t        | ||      }|sdgS |S r   )r   r   s        r   r   r     r   r   c                    t        d|| |      S )Nr   r   r   r   r   r   s       r   r   r     s     wt[AAr   c                    t        d| ||      S )Nr   r   r   s       r   r   r     s     vtUK@@r   c                    g }||z
  }|r<|j                  d|  d       |D ]"  }|j                   |t        |                   $ |S )NzExtra items in the z set:)r;   r   )posnset1set2r   r.   r   items          r   r   r     sT     K$;D0e<=D{8D>:; r   c                   g }t        |       }t        |      }|j                  |      }|D ci c]  }| |   ||   k(  s|| |    }	}|	r|dk  r|dt        |	       dgz  }n4|	r2|dgz  }| |t        j                  |	            j                         z  }|D ch c]  }| |   ||   k7  s| }
}|
rA|dgz  }|
D ]6  }| |t        || |   i            dz    |t        |||   i            z   gz  }8 ||z
  }t        |      }|ri|j                  d| d|d	k(  rd
nd d       |j                   |t        j                  |D ci c]  }|| |   
 c}            j                                ||z
  }t        |      }|ri|j                  d| d|d	k(  rd
nd d       |j                   |t        j                  |D ci c]  }|||   
 c}            j                                |S c c}w c c}w c c}w c c}w )Nrw   	Omitting ! identical items, use -vv to showzCommon items:zDiffering items:r   zLeft contains z
 more itemr4   r3   rG   :zRight contains )	rW   intersectionrB   pprintr   r   r   r;   r   )r   r   r   r   r.   set_left	set_rightcommonksamer   
extra_leftlen_extra_leftextra_rightlen_extra_rights                  r   r   r     s\     K4yHE
I""9-F &>1$q'U1X*=AtAwJD>!)CI;.OPQQ	(({6>>$#78CCEE5v!aE!H!4AvD5*++AHaa\23h58}567 K  I%J_N^,J^q=PrVY6ZZ[\	
 	J'GJq47
J'GHITTV	
 h&K+&Oo.jRS?SY\8]]^_	
 	['I[58['IJKVVX	
 C ? 6  (H (Js"   G.G.G3-G3G8G=c                ,   t        |       sg S t        |       r<dd l}|j                  |       }|D cg c]  }|j                  s|j
                   }}nXt        |       r3| j                  }|D cg c]  }t        |d      s|j
                   }}nt        |       r| j                  }nJ d}	g }
g }|D ]>  }t        | |      t        ||      k(  r|
j                  |       .|j                  |       @ g }|
s|r|dgz  }|
r$|dk  r|j                  dt        |
       d       n4|
r2|dgz  }| |t        j                  |
            j                         z  }|r|d	gz  }| |t        j                  |            j                         z  }|D ]p  }t        | |      }t        ||      }|dd
| d|	 | d |t!        |             d |t!        |             gz  }|t#        ||||      D cg c]  }|	|z   	 c}z  }r |S c c}w c c}w c c}w )Nr   eqr?   r3   rw   r   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute r   z: r   )rr   rd   dataclassesfieldscomparenamerg   rf   r]   r`   r[   r;   rB   r   r   r   r   r   )r   r   r   r   r   
all_fieldsinfofields_to_checkfieldrH   r   r   r.   
field_leftfield_rightrF   s                   r   r   r      sC    $	 ''-
1;Lt||499L	))
3=V:%PTAU5:::V	d	,,uFDD 475%#88KKKK	 ! Ktt!Ys4yk1RST	.//{6>>$#78CCEE/00{6>>$#78CCEEE u-J!%/K6ugQ?(5'KZ0@$A#B${SWXcSdGeFfg K
 +['D  K  W M WDs   HH0HH2Hc                n   |j                  |       }|d | }||t        |       z   d  }||z   }t        ||t        |      }t	        | d       dg}|D ]`  }	|	j                  d      r|	j                  d      r'|	j                  d      r|j                  d|	dd  z          P|j                  |	       b |S )	Nr   )rx   z is contained here:Skippingz- z+ r?   rw   )findrB   r   r(   r   rA   r;   )
termtextr   indexheadtailcorrect_textr   newdiffrF   s
             r   r   r   W  s    IIdOE<DD	!#$D$;LdL*;WED4,--@ABG??:&??4 ??4 NN4$qr(?+NN4   Nr   c                 .    ddg} t        d | D              S )z0Check if we're currently running on a CI system.CIBUILD_NUMBERc              3  @   K   | ]  }|t         j                  v   y wrJ   )osenviron)r   vars     r   r   z running_on_ci.<locals>.<genexpr>m  s     5HSsbjj Hs   )any)env_varss    r   r   r   j  s    n%H5H555r   r   r!   )r.   r"   r#   r"   )r.   r"   r#   	list[str])r/   zSequence[str]r#   r  )rO   r	   r#   bool)r_   r	   r#   r  )r_   objectr#   r  )F)
r   r"   r   r	   r   r	   ru   r  r#   zlist[str] | None)r   )
r   r	   r   r	   r   r   r   intr#   r  )
r   r"   r   r"   r   r   r   r  r#   r  )
r   Iterable[Any]r   r  r   r   r   r  r#   r  )
r   Sequence[Any]r   r  r   r   r   r  r#   r  )
r   AbstractSet[Any]r   r  r   r   r   r  r#   r  )
r   r"   r   r  r   r  r   r   r#   r  )
r   Mapping[Any, Any]r   r  r   r   r   r  r#   r  )r   r"   r   r"   r   r  r#   r  )r#   r  )>__doc__
__future__r   collections.abcrL   r   r   r   r   r   AbstractSetr  r   typingr	   r
   r   unicodedatar   r   r   _pytest._code_pytest._io.pprintr   _pytest._io.safereprr   r   _pytest.configr   r   __annotations__r   r   r   r(   r1   r+   r,   rP   rR   rU   rY   r`   rd   rg   rk   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     s   ( "  $ $ # $ . 	     !   , ) 3 ! DH@ G ;?7 >  6X 6
" FN+PB=		, ?DC#C#C#'*C#7;C#C#N HI"
""(6"AD""L HI4
44(64AD44v 	
   	
 B 	9
99  9 	9
 9@ 		
		  	 		
 	  		
		  	 		
 	  		
		  	 		
 	  	B
BB  B 	B
 B 	A
AA  A 	A
 A

   	
 & 	+
++  + 	+
 +\4
44(64AD44n&6r   