
    9[g)O                       U d Z ddlmZ ddl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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 d5dZ!d6dZ"d7dZ#d8dZ$d8dZ%d8dZ&d8d Z'd9d!Z(d9d"Z)d9d#Z*d9d$Z+	 	 	 	 d:d%Z,	 d;	 	 	 	 	 	 	 	 	 d<d&Z-	 d=	 	 	 	 	 	 	 	 	 d>d'Z.d=d?d(Z/	 d=	 	 	 	 	 	 	 	 	 d@d)Z0	 d=	 	 	 	 	 	 	 	 	 dAd*Z1	 d=	 	 	 	 	 	 	 	 	 dBd+Z2	 d=	 	 	 	 	 	 	 	 	 dBd,Z3	 d=	 	 	 	 	 	 	 	 	 dBd-Z4	 d=	 	 	 	 	 	 	 	 	 dBd.Z5	 d=	 	 	 	 	 	 	 	 	 dBd/Z6	 	 	 	 	 	 	 	 	 	 dCd0Z7	 d=	 	 	 	 	 	 	 	 	 dDd1Z8	 	 	 	 	 	 	 	 	 	 d>d2Z9d=dEd3Z:dFd4Z;y)Gz"Utilities for assertion debugging.    )annotationsN)AbstractSet)Any)Callable)Iterable)Literal)Mapping)Protocol)Sequence)	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      Q/var/www/html/bid-api/venv/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                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_explanationr-   .   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'   =   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.
    Nr0   r   r1   r5   zand   zwhere z +  r2   )r3   r4   r3   )list
startswithr7   lenpop)r+   r,   stackstackcntlinesindents          r   r(   r(   N   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   
issequencerL   q   s(    a112M:a;M7MMr   c                "    t        | t              S rF   )rG   r    rJ   s    r   istextrN   u   s    ar   c                "    t        | t              S rF   )rG   dictrJ   s    r   isdictrQ   y   s    ar   c                .    t        | t        t        f      S rF   )rG   set	frozensetrJ   s    r   issetrU   }   s    a#y)**r   c                D    t        | t              xr t        | dd       d uS )N_fields)rG   tuplegetattrobjs    r   isnamedtupler\      s"    c5!Ogc9d&C4&OOr   c                     t        | dd       d uS )N__dataclass_fields__rY   rZ   s    r   	isdataclsr`      s    3.5TAAr   c                     t        | dd       d uS )N__attrs_attrs__r_   rZ   s    r   isattrsrc      s    3)40<<r   c                P    	 t        |        t        |        S # t        $ r Y yw xY w)NF)iterrN   	ExceptionrZ   s    r   
isiterablerg      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 eqz<string>T)hasattr__eq__ri   rj   rc   )r[   code_filenames     r   has_default_eqrn      sZ     szz:&73::3F3F+V

++773<'=88
**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.NFDr0   )	use_asciiA      )maxsizerq    Nz==znot inz!=Both sets are equalz>=z<=r4   <z<(pytest_assertion plugin: representation of details failed: .z+ Probably an object has a faulty __repr__.)r   r/   )get_verbosityr   VERBOSITY_ASSERTIONSrG   r    r   r   r>   r   get_terminal_writer
_highlight_compare_eq_anyrN   _notin_textrU   _compare_gte_set_compare_lte_set_compare_gt_set_compare_lt_setr   Exitrf   _pytest_codeExceptionInfofrom_current_getreprcrash)configopleftrightrq   verbose	left_repr
right_reprrt   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)rN   
_diff_text_pytest.python_apir   rG   _repr_comparetyper`   rc   r\   _compare_eq_clsrL   _compare_eq_sequencerU   _compare_eq_setrQ   _compare_eq_dictrg   _compare_eq_iterableextend)	r   r   r   r   r*   r   approx_side
other_sideexpls	            r   r}   r}      s6    Kd|u ug6: 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                  |      | j                  |            D cg c]  }|j                  d       c}z  }|S c c}w )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   )ndiffr0   *   
   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&   )
difflibr   rangeminr>   isspacereprr    
splitlinesstrip)r   r   r   r   r*   ikeependsrB   s           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 %**84dooh6OPPD 	

4P K 	s   =E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 diffr/   z
Full diff:r&   c              3  <   K   | ]  }|j                           y wrF   )rstrip).0rB   s     r   	<genexpr>z'_compare_eq_iterable.<locals>.<genexpr>X  s      LD Ls   diff)r   )running_on_cir   r   pformatr   r   r)   r   )r   r   r   r   r   left_formattingright_formattingr*   s           r   r   r   E  s     !|MO)**#o--d3>>@O$..u5@@B|$K II #MM*:OL  	
 *, r   c                2   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
  }|rU|dkD  rd}t        | |         }nd|z
  }d}t        ||         }|dk(  r|| d ||       gz  }|S |d	|| ||      fz  gz  }|S )
Nr0   z	At index z diff:  != r   LeftRightz contains one more item: z/%s contains %d more items, first extra item: %s)rG   bytesr>   r   r   r7   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   b  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 	 A (K,>?@ 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 Nrv   )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:)r7   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        |      }|rg|j                  d||dk(  rd	nd
fz         |j                   |t        j                  |D ci c]  }|| |   
 c}            j                                ||z
  }t        |      }|rg|j                  d||dk(  rd	nd
fz         |j                   |t        j                  |D ci c]  }|||   
 c}            j                                |S c c}w c c}w c c}w c c}w )Nrs   	Omitting ! identical items, use -vv to showzCommon items:zDiffering items:r   zLeft contains %d more item%s:r0   r/   rC   zRight contains %d more item%s:)	rS   intersectionr>   pprintr   r   r   r7   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     sQ     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+^q%8rcBC	
 	J'GJq47
J'GHITTV	
 h&K+&O,o&:DE	
 	['I[58['IJKVVX	
 G ? 6" (H (Js"   G*G*G/-G/G4>G9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;   r/   rs   r   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute :z: r   )rn   r`   dataclassesfieldscomparenamerc   rb   rY   r\   rW   r7   r>   r   r   r   r   r}   )r   r   r   r   r   
all_fieldsinfofields_to_checkfieldrD   r   r   r*   
field_leftfield_rightrB   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                d   |j                  |       }|d | }||t        |       z   d  }||z   }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   )rt   z is contained here:Skippingz- z+ r;   rs   )findr>   r   r   r=   r7   )
termtextr   indexheadtailcorrect_textr   newdiffrB   s
             r   r~   r~   K  s    IIdOE<DD	!#$D$;LdL'2D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rF   )osenviron)r   vars     r   r   z running_on_ci.<locals>.<genexpr>a  s     5HSsbjj Hs   )any)env_varss    r   r   r   ^  s    n%H5H555r   )r*   r    r!   r    )r*   r    r!   	list[str])r+   zSequence[str]r!   r  )rK   r   r!   bool)r[   r   r!   r  )r[   objectr!   r  )F)
r   r    r   r   r   r   rq   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   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.abcrH   r   r   typingr   r   r   r   r   r	   r
   r   unicodedatar   r   r   _pytest._code_pytest._io.pprintr   _pytest._io.safereprr   r   _pytest.configr   r   __annotations__r   r   r   r-   r'   r(   rL   rN   rQ   rU   r\   r`   rc   rg   rn   r   r}   r   r   r   r   r   r   r   r   r   r   r   r~   r   r   r   r   <module>r     st   ( "  	          !   , ) 3 ! DH@ G ;?7 >  6X 6
" FN+PB=		, ?DC#C#C#'*C#7;C#C#N HI"
""(6"AD""J-h 	
   	
 B 	:
::  : 	:
 :B 		
		  	 		
 	  		
		  	 		
 	  		
		  	 		
 	  	B
BB  B 	B
 B 	A
AA  A 	A
 A

   	
 & 	-
--  - 	-
 -`4
44(64AD44n&6r   