
    pj)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 dRdZ!dSdZ"dTd"Z#dUd&Z$dUd'Z%dUd(Z&dUd)Z'dVd+Z(dVd,Z)dVd-Z*dVd.Z+dWd0Z,	 dXdYd7Z-	 dZd[d;Z.dZd\d<Z/	 dZd]d>Z0	 dZd^d@Z1	 dZd_dBZ2	 dZd_dCZ3	 dZd_dDZ4	 dZd_dEZ5	 dZd_dFZ6d`dJZ7	 dZdadLZ8d[dMZ9dZdbdPZ:dcdQZ;dS )dz"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dS )_HighlightFuncpythonsourcestrlexerLiteral['diff', 'python']returnc                    dS )z'Apply highlighting to the given source.N )selfr   r   s      f/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/_pytest/assertion/util.py__call__z_HighlightFunc.__call__*   s          N)r   )r   r   r   r   r   r   )__name__
__module____qualname__r!   r   r"   r    r   r   )   s-        6 6 6 6 6 6 6r"   r   explanationr   r   c                h    t          |           }t          |          }d                    |          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.   .   s0     {++E5!!F99Vr"   	list[str]c                    | pd                     d          }|d         g}|dd         D ]7}|r |d         dv r|                    |           $|dxx         d|z   z  cc<   8|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)   =   s     "))$//Iq\NEABB- ( ( 	(fQi#777LL    "III'IIIILr"   r,   Sequence[str]c                r   t          | dd                   }dg}dg}| dd         D ]x}|                    d          r|d         rd}nd}|                    t          |                     |dxx         dz  cc<   |                    d           |                    dd	t          |          dz
  z  z   |z   |dd         z              |                    d
          rH|                                 |                                 ||d         xx         |dd         z  cc<   |d         dv sJ |dxx         dz  cc<   |                    d          rt          |          nt          |          dz
  }|                    d	|z  |dd         z              zt          |          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   s    %)__FCEsHabb	 4 4??3 	4| LLV%%%RLLLALLLOOAMM$Ua!881<tABBxGHHHH__S!! 	4IIKKKLLNNN59abb)7j(((("IIINIII#'??3#7#7KSZZZSZZ!^FMM$-$qrr(23333u::????Mr"   xr   boolc                l    t          | t          j        j                  ot          | t                     S N)
isinstancecollectionsabcr   r   rH   s    r    
issequencerP   q   s)    a122M:a;M;M7MMr"   c                ,    t          | t                    S rK   )rL   r   rO   s    r    istextrR   u   s    ar"   c                ,    t          | t                    S rK   )rL   dictrO   s    r    isdictrU   y   s    ar"   c                :    t          | t          t          f          S rK   )rL   set	frozensetrO   s    r    issetrY   }   s    a#y)***r"   objc                R    t          | t                    ot          | dd           d uS )N_fields)rL   tuplegetattrrZ   s    r    isnamedtupler`      s(    c5!!Ogc9d&C&C4&OOr"   c                (    t          | dd           d uS )N__dataclass_fields__r^   r_   s    r    	isdataclsrd      s    3.55TAAr"   c                (    t          | dd           d uS )N__attrs_attrs__rc   r_   s    r    isattrsrg      s    3)400<<r"   c                d    	 t          |            t          |            S # t          $ r Y dS w xY w)NF)iterrR   	Exceptionr_   s    r    
isiterablerk      sB    S			#;;   uus   ! 
//objectc                    t          | j        d          rDt          | j        j        d          r*| j        j        j        }t	          |           rd|v S |dk    S dS )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__rn   ro   rg   )rZ   code_filenames     r    has_default_eqrs      sd     sz:&& +73:3F+V+V +
+73<< 	9'=88
**4r"   Fopleftright	use_asciilist[str] | Nonec                   |                      t          j                  }t          |t                    o6t          |t                    o!t          d|          t          d|          k    }|dk    r#t          ||          }t          ||          }n<dt          |          z
  dz
  dz  }t          |||          }t          |||          }| d| d| }	| 	                                j
        }
d}	 |d	k    rt          |||
|          }n:|d
k    r1t          |          r t          |          rt          |||          }n|dk    r"t          |          rt          |          rdg}n|dk    r1t          |          r!t          |          rt          |||
|          }n|dk    r1t          |          r!t          |          rt!          |||
|          }nm|dk    r1t          |          r!t          |          rt#          |||
|          }n6|dk    r0t          |          r!t          |          rt%          |||
|          }n\# t&          j        $ r  t*          $ r@ t,          j        j                                                                        }d| ddg}Y nw xY w|sdS |d         dk    rdg|}|	g|S )z<Return specialised explanations for some operators/operands.NFDr2   )rw   A      )maxsizerw    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_ASSERTIONSrL   r   r   r   rA   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)configrt   ru   rv   rw   verbose	left_repr
right_reprr}   summaryhighlighterr&   
repr_crashs                r    assertrepr_comparer      s(    ""6#>??G
 	4 	>uc""	>eT""iu&=&==  {{&tyAAA	'CCC


 c"gg! T7iHHH	eW	JJJ
..R..*..G,,..9KK
::)${GLLKK8^^d|| @u @)$w??4ZZT{{ 6uU|| 6454ZZT{{ RuU|| R.tUKQQ4ZZT{{ RuU|| R.tUKQQ3YYT{{ QuU|| Q-dE;PP3YYT{{ QuU|| Q-dE;PP=    
 
 
]0==??MMOO
X:XXX9

  t1~(K("k""s   7EI AJ%$J%r   r   intc                   g }t          |           r"t          |          rt          | ||          }nddlm} t	          | |          st	          ||          r>t	          | |          r| n|}t	          | |          r|n| }|                    |          }nt          |           t          |          u r@t          |           st          |           st          |           rt          | |||          }nt          |           r"t          |          rt          | |||          }nat          |           r"t          |          rt          | |||          }n0t          |           r!t          |          rt!          | |||          }t#          |           r6t#          |          r't%          | |||          }|                    |           |S )Nr   )
ApproxBase)rR   
_diff_text_pytest.python_apir   rL   _repr_comparetyperd   rg   r`   _compare_eq_clsrP   _compare_eq_sequencerY   _compare_eq_setrU   _compare_eq_dictrk   _compare_eq_iterableextend)	ru   rv   r   r   r&   r   approx_side
other_sideexpls	            r    r   r      s    Kd|| %u % ug66111111dJ'' 	N:eZ+H+H 	N",T:">">I$$EK",T:">">HDJ%33J??KK$ZZ4;;&&dOO '&t}} '0<T0B0B ' *${GLLKK 	N*U"3"3 	N.tUKQQKK4[[ 	NU5\\ 	N)${GLLKKD\\ 	NfUmm 	N*4WMMKd 	%
5 1 1 	%'e['JJDt$$$r"   c                \   ddl m} g }|dk     rd}t          t          t	          |           t	          |                              D ]}| |         ||         k    r n|dk    r |dz  }d| dg}| |d         } ||d         }t	          |           t	          |          k    r`t          t	          |                     D ]}| |          ||          k    r n|dk    r%|dz  }|d| d	gz  }| d|          } |d|          }d
}|                                 s|                                r>t          t          |                     } t          t          |                    }|dgz  }|d  ||                    |          |                     |                    D             z  }|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   )ndiffr2   *   
   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()c                8    g | ]}|                     d           S )r(   )strip.0rE   s     r    
<listcomp>z_diff_text.<locals>.<listcomp>>  s4        	

4  r"   )	difflibr   rangeminrA   isspacereprr   
splitlines)ru   rv   r   r   r&   ikeependss          r    r   r     s    K{{s3t99c%jj1122 	 	AAw%("" #r66GATATTTK 8D!""IEt99E

""3t99%%  8uaRy((E )2vvR9 9 9 9   CaRCycrc
H||~~ W WCIISZZ  UVV   E%**844dooh6O6OPP   K r"   Iterable[Any]c                   |dk    rt                      sdgS dd l}t                                          |                                           }t                                          |                                          }ddg}|                     |d                    d |                    ||          D                       d                                                     |S )	Nr   zUse -v to get more diffr1   z
Full diff:r(   c              3  >   K   | ]}|                                 V  d S rK   )rstripr   s     r    	<genexpr>z'_compare_eq_iterable.<locals>.<genexpr>X  s>              r"   diff)r   )running_on_cir   r   pformatr   r   r+   r   )ru   rv   r   r   r   left_formattingright_formattingr&   s           r    r   r   E  s     !||MOO|)**NNN#oo--d33>>@@O$..u55@@BB|$K II  #MM*:OLL     	
 	
 	
 *,,   r"   Sequence[Any]c                   t          | t                    ot          |t                    }g }t          |           }t          |          }t          t	          ||                    D ]}| |         ||         k    ry|r| ||dz            }	|||dz            }
n| |         }	||         }
|                    d| d |t          |	                     d |t          |
                                 n|r|S ||z
  }|rj|dk    rd}t          | |                   }nd|z
  }d}t          ||                   }|dk    r|| d ||           gz  }n|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)rL   bytesrA   r   r   r9   r   r   )ru   rv   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*UE2J2JOK4yyHE

I3x++,,  7eAh ' "!a!e)_
#AAI.!!W
#AhXA X XKZ 0 011X X7B{4CTCT7U7UX X   E) ,   )#H a<<"MT)_--EE8|H#MU8_--Eq== OO;;u;M;MOO KK A (KK,>,>?@ K r"   AbstractSet[Any]c                    g }|                     t          d| ||                     |                     t          d|| |                     |S )Nru   rv   )r   _set_one_sided_diffru   rv   r   r   r&   s        r    r   r     sU     K*64LLMMM*7E4MMNNNr"   c                2    t          | ||          }|sdgS |S Nr   )r   r   s        r    r   r     ,     #4<<K '%&&r"   c                2    t          | ||          }|sdgS |S r   )r   r   s        r    r   r     r   r"   c                &    t          d|| |          S )Nrv   r   ru   rv   r   r   s       r    r   r     s     wt[AAAr"   c                &    t          d| ||          S )Nru   r   r   s       r    r   r     s     vtUK@@@r"   posnset1set2c                    g }||z
  }|rI|                     d|  d           |D ]-}|                      |t          |                               .|S )NzExtra items in the z set:)r9   r   )r   r   r   r   r&   r   items          r    r   r     sv     K$;D <<<<<=== 	< 	<D{{8D>>::;;;;r"   Mapping[Any, Any]c           
     &    g }t                     }t                    }|                    |          } fd|D             }|r|dk     r|dt          |           dgz  }n:|r8|dgz  }| |t          j        |                                                    z  } fd|D             }	|	rS|dgz  }|	D ]J}
| |t          |
 |
         i                    dz    |t          |
|
         i                    z   gz  }K||z
  }t          |          }|rp|                    d	||d
k    rdndfz             |                     |t          j         fd|D                                                                            ||z
  }t          |          }|rp|                    d||d
k    rdndfz             |                     |t          j        fd|D                                                                            |S )Nc                F    i | ]}|         |         k    ||         S r   r   r   kru   rv   s     r    
<dictcomp>z$_compare_eq_dict.<locals>.<dictcomp>  s1    >>>1$q'U1X*=*=AtAw*=*=*=r"   r|   	Omitting ! identical items, use -vv to showzCommon items:c                8    h | ]}|         |         k    |S r   r   r   s     r    	<setcomp>z#_compare_eq_dict.<locals>.<setcomp>  s+    555!aE!H!4!4A!4!4!4r"   zDiffering items:r   zLeft contains %d more item%s:r2   r1   rF   c                "    i | ]}||         S r   r   )r   r   ru   s     r    r   z$_compare_eq_dict.<locals>.<dictcomp>  s    'G'G'Gq47'G'G'Gr"   zRight contains %d more item%s:c                "    i | ]}||         S r   r   )r   r   rv   s     r    r   z$_compare_eq_dict.<locals>.<dictcomp>  s    'I'I'I58'I'I'Ir"   )	rW   intersectionrA   pprintr   r   r   r9   r   )ru   rv   r   r   r&   set_left	set_rightcommonsamer   r   
extra_leftlen_extra_leftextra_rightlen_extra_rights   ``             r    r   r     s     K4yyHE

I""9--F>>>>>>>>D F!PCIIPPPQQ	 F(({{6>$#7#788CCEEE55555v555D *++ 	 	AHaa\2233+h58}55667 KK
 I%J__N 
+^q%8%8rrcBC	
 	
 	
 	K'G'G'G'GJ'G'G'GHHIITTVV	
 	
 	
 h&K+&&O 
,o&:&:DE	
 	
 	
 	K'I'I'I'I['I'I'IJJKKVVXX	
 	
 	
 r"   c                *   t          |           sg S t          |           r&dd l}|                    |           }d |D             }n<t	          |           r| j        }d |D             }nt          |           r| j        }nJ dg }g }|D ]O}	t          | |	          t          ||	          k    r|	                    |	           :|	                    |	           Pg }
|s|r|
dgz  }
|r-|dk     r'|
	                    dt          |           d	           n:|r8|
d
gz  }
|
 |t          j        |                                                    z  }
|r|
dgz  }
|
 |t          j        |                                                    z  }
|D ]}	t          | |	          }t          ||	          }|
dd|	 d |	 d |t          |                     d |t          |                     gz  }
|
fdt          ||||          D             z  }
|
S )Nr   c                *    g | ]}|j         	|j        S r   )comparename)r   infos     r    r   z#_compare_eq_cls.<locals>.<listcomp>  s!    LLLt|L49LLLr"   c                <    g | ]}t          |d           |j        S )eq)r^   r   )r   fields     r    r   z#_compare_eq_cls.<locals>.<listcomp>   s*    VVV%PTAUAUV5:VVVr"   Fr>   r1   r|   r   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute :z: r   c                    g | ]}|z   S r   r   )r   rE   rG   s     r    r   z#_compare_eq_cls.<locals>.<listcomp>B  s-          r"   )rs   rd   dataclassesfieldsrg   rf   r`   r\   r^   r9   rA   r   r   r   r   r   )ru   rv   r   r   r  
all_fieldsfields_to_checkr   r   r  r&   
field_leftfield_rightrG   s                @r    r   r     s    $ 	  ''--
LLLLL	 )
VV:VVV	d		 ,uFDD   475%#8#888KKKKK t t F!Ss4yySSSTTTT	 F.//{{6>$#7#788CCEEE /00{{6>$#7#788CCEEE 	 	E u--J!%//K?u???g5ggKKZ0@0@$A$Agg{{SWXcSdSdGeGegg K
     +['    KK r"   termtextc                   |                     |           }|d |         }||t          |           z   d          }||z   }t          |||          }t          | d           dg}|D ]y}	|	                    d          r|	                    d          r.|	                    d          r!|                    d|	dd          z              d|                    |	           z|S )	Nr   )r}   z is contained here:Skippingz- z+ r>   r|   )findrA   r   r   r@   r9   )
r
  r  r   indexheadtailcorrect_textr   newdiffrE   s
             r    r   r   K  s    IIdOOE<DD		!##$D$;LdL'22D4,,,AAABG ! !??:&& 	??4   	??4   	!NN4$qrr(?++++NN4    Nr"   c                 <    ddg} t          d | D                       S )z0Check if we're currently running on a CI system.CIBUILD_NUMBERc              3  2   K   | ]}|t           j        v V  d S rK   )osenviron)r   vars     r    r   z running_on_ci.<locals>.<genexpr>a  s)      55Ssbj 555555r"   )any)env_varss    r    r   r   ^  s)    n%H55H555555r"   )r&   r   r   r   )r&   r   r   r/   )r,   r<   r   r/   )rH   r   r   rI   )rZ   r   r   rI   )rZ   rl   r   rI   )F)
rt   r   ru   r   rv   r   rw   rI   r   rx   )r   )
ru   r   rv   r   r   r   r   r   r   r/   )ru   r   rv   r   r   r   r   r/   )
ru   r   rv   r   r   r   r   r   r   r/   )
ru   r   rv   r   r   r   r   r   r   r/   )
ru   r   rv   r   r   r   r   r   r   r/   )
r   r   r   r   r   r   r   r   r   r/   )
ru   r   rv   r   r   r   r   r   r   r/   )r
  r   r  r   r   r   r   r/   )r   rI   )<__doc__
__future__r   collections.abcrM   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*   rP   rR   rU   rY   r`   rd   rg   rk   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r    <module>r'     se   ( ( ( " " " " " "     				                                                  ! ! ! ! ! !           , , , , , , ) ) ) ) ) ) 3 3 3 3 3 3 ! ! ! ! ! ! DH G G G G ;? > > > >     6 6 6 6 6X 6 6 6
      "       FN N N N      + + + +P P P PB B B B= = = =      , ?DC# C# C# C# C#N HI" " " " "J- - - - -h 	    B 	: : : : :B 		 	 	 	 	  		 	 	 	 	  		 	 	 	 	  	B B B B B 	A A A A A   & 	- - - - -`4 4 4 4n    &6 6 6 6 6 6r"   