
    [FiNO                        U d 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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eeeeegee   f      ed<   dZ eee!eegdf      ed<   dZ"ee   ed<    G d de      Z#dedefdZ$dede
e   fdZ%dee   de
e   fdZ&dede'fdZ(dede'fd Z)dede'fd!Z*dede'fd"Z+d#ede'fd$Z,d#ede'fd%Z-d#ede'fd&Z.d#ede'fd'Z/d#ede'fd(Z0	 dDd)ed*ed+ed,e'dee
e      f
d-Z1	 dEd*ed+ed.e#d/e!de
e   f
d0Z2dEd*ed+ed/e!de
e   fd1Z3	 dEd*e	e   d+e	e   d2e#d/e!de
e   f
d3Z4	 dEd*ee   d+ee   d.e#d/e!de
e   f
d4Z5	 dEd*ee   d+ee   d.e#d/e!de
e   f
d5Z6	 dEd*ee   d+ee   d.e#d/e!de
e   f
d6Z7	 dEd*ee   d+ee   d.e#d/e!de
e   f
d7Z8	 dEd*ee   d+ee   d.e#d/e!de
e   f
d8Z9	 dEd*ee   d+ee   d.e#d/e!de
e   f
d9Z:d:ed;ee   d<ee   d.e#de
e   f
d=Z;	 dEd*eeef   d+eeef   d.e#d/e!de
e   f
d>Z<d*ed+ed.e#d/e!de
e   f
d?Z=dEd@edAed/e!de
e   fdBZ>de'fdCZ?y)Fz"Utilities for assertion debugging.    N)AbstractSet)Any)Callable)Iterable)List)Literal)Mapping)Optional)Protocol)Sequence)	normalize)outcomes)PrettyPrinter)saferepr)saferepr_unlimited)Config_reprcompare_assertion_pass_configc                   (    e Zd Zddeded   defdZy)_HighlightFuncsourcelexer)diffpythonreturnc                      y)z'Apply highlighting to the given source.N )selfr   r   s      h/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/_pytest/assertion/util.py__call__z_HighlightFunc.__call__*   s        N)r   )__name__
__module____qualname__strr   r!   r   r"   r    r   r   )   s#    6s 673C+D 6TW 6r"   r   explanationr   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)r'   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*   =   sm     "))$/Iq\NEAB- (fQi#77LL "I'I	(
 Lr"   r-   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.
    Nr2   r   r3   r7   zand   zwhere z +  r4   )r5   r6   r5   )list
startswithr9   lenpop)r-   r.   stackstackcntlinesindents          r    r+   r+   N   sR    %)_FCEsHab	 4??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%4& u:??Mr"   xc                 p    t        | t        j                  j                        xr t        | t               S N)
isinstancecollectionsabcr   r&   rG   s    r    
issequencerN   q   s(    a112M:a;M7MMr"   c                 "    t        | t              S rI   )rJ   r&   rM   s    r    istextrP   u   s    ar"   c                 "    t        | t              S rI   )rJ   dictrM   s    r    isdictrS   y   s    ar"   c                 .    t        | t        t        f      S rI   )rJ   set	frozensetrM   s    r    issetrW   }   s    a#y)**r"   objc                 D    t        | t              xr t        | dd       d uS )N_fields)rJ   tuplegetattrrX   s    r    isnamedtupler^      s"    c5!Ogc9d&C4&OOr"   c                      t        | dd       d uS )N__dataclass_fields__r\   r]   s    r    	isdataclsrb      s    3.5TAAr"   c                      t        | dd       d uS )N__attrs_attrs__ra   r]   s    r    isattrsre      s    3)40<<r"   c                 P    	 t        |        t        |        S # t        $ r Y yw xY w)NF)iterrP   	Exceptionr]   s    r    
isiterableri      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__rk   rl   re   )rX   code_filenames     r    has_default_eqrp      sZ     szz:&73::3F3F+V

++773<'=88
**r"   opleftright	use_asciic                    | 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.NFDr2   )rt   A      )maxsizert    Nz==znot inz!=Both sets are equalz>=z<=r6   <z<(pytest_assertion plugin: representation of details failed: .z+ Probably an object has a faulty __repr__.)r   r1   )get_verbosityr   VERBOSITY_ASSERTIONSrJ   r&   r   r   r@   r   get_terminal_writer
_highlight_compare_eq_anyrP   _notin_textrW   _compare_gte_set_compare_lte_set_compare_gt_set_compare_lt_setr   Exitrh   _pytest_codeExceptionInfofrom_current_getreprcrash)configrq   rr   rs   rt   verbose	left_repr
right_reprry   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	r   r   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)rP   
_diff_text_pytest.python_apir   rJ   _repr_comparetyperb   re   r^   _compare_eq_clsrN   _compare_eq_sequencerW   _compare_eq_setrS   _compare_eq_dictri   _compare_eq_iterableextend)	rr   rs   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|z  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   )ndiffr2   *   
   z@Skipping %s identical leading characters in diff, use -v to showNz	Skipping z6 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)rr   rs   r   r   r'   ikeependsrD   s           r    r   r     s    K{s3t9c%j12 	AAw%("	 r6GARUVV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 	

4 K 	s   <E
highligherc                 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 diffr1   z
Full diff:r)   c              3   <   K   | ]  }|j                           y wrI   )rstrip).0rD   s     r    	<genexpr>z'_compare_eq_iterable.<locals>.<genexpr>X  s       s   r   )r   )running_on_cir   r   pformatr   r   r,   r   )rr   rs   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 )
Nr2   z	At index z diff:  != r   LeftRightz contains one more item: z/%s contains %d more items, first extra item: %s)rJ   bytesr@   r   r   r9   r   r   )rr   rs   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 )Nrr   rs   )r   _set_one_sided_diffrr   rs   r   r   r'   s        r    r   r     sC     K*64LM*7E4MNr"   c                 *    t        | ||      }|sdgS |S Nr{   )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 )Nrs   r   rr   rs   r   r   s       r    r   r     s     wt[AAr"   c                     t        d| ||      S )Nrr   r   r   s       r    r   r     s     vtUK@@r"   posnset1set2c                     g }||z
  }|r<|j                  d|  d       |D ]"  }|j                   |t        |                   $ |S )NzExtra items in the z set:)r9   r   )r   r   r   r   r'   r   items          r    r   r     sY     K$;D0e<= 	<D{8D>:;	<r"   c                    g }t        |       }t        |      }|j                  |      }|D ci c]  }| |   ||   k(  s|| |    }	}|	r|dk  r|dt        |	      z  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 )Nrx   ,Omitting %s identical items, use -vv to showzCommon items:zDiffering items:r   zLeft contains %d more item%s:r2   r1   rE   zRight contains %d more item%s:)	rU   intersectionr@   pprintr   r   r   r9   r   )rr   rs   r   r   r'   set_left	set_rightcommonksamer   
extra_leftlen_extra_leftextra_rightlen_extra_rights                  r    r   r     sH     K4yHE
I""9-F &>1$q'U1X*=AtAwJ>D>!FTRSS	(({6>>$#78CCEE5!aE!H!4A5D5*++ 	AHaa\23h58}567 K	 I%J_N+^q%8rcBC	
 	J'Gq47
'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.G3=G8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        |
      z         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=   r1   rx   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute :z: r   )rp   rb   dataclassesfieldscomparenamere   rd   r\   r^   rZ   r9   r@   r   r   r   r   r   )rr   rs   r   r   r   
all_fieldsinfofields_to_checkfieldrF   r   r   r'   
field_leftfield_rightrD   s                   r    r   r     s?    $	 ''-
1;Lt||499LL	))
3=V%PTAU5::VV	d	,,uFDD  475%#88KKKK	 Ktt!ICPTIUV	.//{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
 +['  K	 W M WDs   HH0HH1Htermtextc                 d   |j                  |       }|d | }||t        |       z   d  }||z   }t        |||      }dt        | d      z  g}|D ]`  }	|	j	                  d      r|	j	                  d      r'|	j	                  d      r|j                  d|	dd  z          P|j                  |	       b |S )	Nz%s is contained here:r   )ry   Skippingz- z+ r=   rx   )findr@   r   r   r?   r9   )
r   r   r   indexheadtailcorrect_textr   newdiffrD   s
             r    r   r   K  s    IIdOE<DD	!#$D$;LdL'2D&$)CCDG !??:&??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rI   )osenviron)r   vars     r    r   z running_on_ci.<locals>.<genexpr>a  s     5Ssbjj 5s   )any)env_varss    r    r   r   ^  s    n%H5H555r"   )F)r   )@__doc__collections.abcrK   r  r   typingr   r   r   r   r   r   r	   r
   r   r   unicodedatar   r   r   _pytest._code_pytest._io.pprintr   _pytest._io.safereprr   r   _pytest.configr   r   r&   object__annotations__r   intr   r   r/   r*   r+   boolrN   rP   rS   rW   r^   rb   re   ri   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r    <module>r     s0   (  	            !   , ) 3 ! JNhxff 5x} DEF M >B(Cc?D#89: A !&	  6X 6
C C C DI " #  49  FN# N$ Nc d c d +S +T +Pc Pd PB3 B4 B= = =C D 		, ?DC#C#C#'*C#7;C#d3iC#N HI"
""(6"AD"	#Y"J-S - -s -49 -h 	
3-C=  	
 
#YB 	:
3-:C=:  : 	:
 
#Y:B 		
c
	s	  	 		
 
#Y	  		
c
	s	  	 		
 
#Y	  		
c
	s	  	 		
 
#Y	  	B
c
BsB  B 	B
 
#YB 	A
c
AsA  A 	A
 
#YA

c
 c
  	
 
#Y& 	-
#s(
-38-  - 	-
 
#Y-`4
44(64AD4	#Y4nc  s 49 &6t 6r"   