
    ?g'O                    T   % S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSKJ
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJr  SrS\S'   SrS\S'   SrS\S'    " S S\5      r S5S jr!S6S jr"S7S jr#S8S jr$S8S jr%S8S jr&S8S  jr'S9S! jr(S9S" jr)S9S# jr*S9S$ jr+    S:S% jr, S;         S<S& jjr- S=         S>S' jjr.S=S?S( jjr/ S=         S@S) jjr0 S=         SAS* jjr1 S=         SBS+ jjr2 S=         SBS, jjr3 S=         SBS- jjr4 S=         SBS. jjr5 S=         SBS/ jjr6          SCS0 jr7 S=         SDS1 jjr8          S>S2 jr9S=SES3 jjr:SFS4 jr;g)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                  "    \ rS rSrSSS jjrSrg)_HighlightFunc)   c                    g)z'Apply highlighting to the given source.N )selfsourcelexers      8/usr/lib/python3/dist-packages/_pytest/assertion/util.py__call___HighlightFunc.__call__*   s        r   N)python)r   strr   zLiteral['diff', 'python']returnr"   )__name__
__module____qualname____firstlineno__r   __static_attributes__r   r    r   r   r   )   s    6 6r    r   c                P    [        U 5      n[        U5      nSR                  U5      $ )an  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   .   s'     {+E5!F99Vr    c                    U =(       d    SR                  S5      nUS   /nUSS  H6  nU(       a  US   S;   a  UR                  U5        M&  US==   SU-   -  ss'   M8     U$ )	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                   [        U SS 5      nS/nS/nU SS  GH:  nUR                  S5      (       au  US   (       a  SnOSnUR                  [        U5      5        US==   S-  ss'   UR                  S5        UR                  SS	[        U5      S-
  -  -   U-   USS -   5        M  UR                  S
5      (       a4  UR	                  5         UR	                  5         XS   ==   USS -  ss'   M  US   S;   d   eUS==   S-  ss'   UR                  S5      (       a  [        U5      O[        U5      S-
  nUR                  S	U-  USS -   5        GM=     [        U5      S:X  d   eU$ )zFormat 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,   N   sT    %)_FCEsHab	??3|LLV%RLALOOAMM$Ua!881<tABxGH__S!!IIKLLN9ab)7j((("INI#'??3#7#7SZSZ!^FMM$-$qr(23% & u:??Mr    c                    [        U [        R                  R                  5      =(       a    [        U [        5      (       + $ N)
isinstancecollectionsabcr   r"   xs    r   
issequencerP   q   s(    a112M:a;M7MMr    c                "    [        U [        5      $ rJ   )rK   r"   rN   s    r   istextrR   u   s    ar    c                "    [        U [        5      $ rJ   )rK   dictrN   s    r   isdictrU   y   s    ar    c                .    [        U [        [        45      $ rJ   )rK   set	frozensetrN   s    r   issetrY   }   s    a#y)**r    c                N    [        U [        5      =(       a    [        U SS 5      S L$ )N_fields)rK   tuplegetattrobjs    r   isnamedtupler`      s"    c5!Ogc9d&C4&OOr    c                     [        U SS 5      S L$ )N__dataclass_fields__r]   r^   s    r   	isdataclsrd      s    3.5TAAr    c                     [        U SS 5      S L$ )N__attrs_attrs__rc   r^   s    r   isattrsrg      s    3)40<<r    c                Z     [        U 5        [        U 5      (       + $ ! [         a     gf = f)NF)iterrR   	Exceptionr^   s    r   
isiterablerk      s,    S	#; s    
**c                    [        U R                  S5      (       a_  [        U R                  R                  S5      (       a:  U R                  R                  R                  n[	        U 5      (       a  SU;   $ US:H  $ g)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      sb     szz:&&73::3F3F+V+V

++773<<%66
**r    c                   U R                  [        R                  5      n[        U[        5      =(       a0    [        U[        5      =(       a    [        SU5      [        SU5      :H  nUS:  a  [        X$S9n[        X4S9nO(S[        U5      -
  S-
  S-  n[        X(US9n[        X8US9nU SU SU 3n	U R                  5       R                  n
Sn US	:X  a  [        X#X5      nGO(US
:X  a-  [        U5      (       a  [        U5      (       a  [        X#U5      nOUS:X  a$  [        U5      (       a  [        U5      (       a  S/nOUS:X  a-  [        U5      (       a  [        U5      (       a  [        X#X5      nOUS:X  a-  [        U5      (       a  [        U5      (       a  [!        X#X5      nOeUS:X  a-  [        U5      (       a  [        U5      (       a  [#        X#X5      nO2US:X  a,  [        U5      (       a  [        U5      (       a  [%        X#X5      nU(       d  gUS   S:w  a  S/UQnU	/UQ$ ! [&        R(                   a    e [*         aA    [,        R.                  R0                  R3                  5       R5                  5       nSU S3S/n Nyf = f)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      sP    ""6#>#>?G
 	4 	>uc"	>eT"iu&==  {&tA	'C

 c"g! TiH	e	J
1RD*.G,,.99KK
:)${LK8^d||u)$w?4ZT{{uU||454ZT{{uU||.tKQ4ZT{{uU||.tKQ3YT{{uU||-d;P3YT{{uU||-d;P 1~(K("k"" ==  
]]00==?MMO
J:,VWX9

s7   H& #2H& )H&  2H& 32H& &2H& 2H& &AJJc                T   / n[        U 5      (       a  [        U5      (       a  [        XU5      nU$ SSKJn  [	        X5      (       d  [	        X5      (       a:  [	        X5      (       a  U OUn[	        X5      (       a  UOU nUR                  U5      nO[        U 5      [        U5      L a=  [        U 5      (       d   [        U 5      (       d  [        U 5      (       a  [        XX#5      nO[        U 5      (       a  [        U5      (       a  [        XX#5      nOY[        U 5      (       a  [        U5      (       a  [        XX#5      nO,[        U 5      (       a  [        U5      (       a  [!        XX#5      n[#        U 5      (       a-  [#        U5      (       a  [%        XX#5      nUR'                  U5        U$ )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      sC    Kd||u g6: 7 	2d'':e+H+H",T">">$EK",T">">DJ%33J?K$Z4;&dOOwt}}T0B0B *${LK*U"3"3.tKQK4[[U5\\)${LKD\\fUmm*4MKd
5 1 1'[JDt$r    c                   SSK Jn  / nUS:  a  Sn[        [        [	        U 5      [	        U5      5      5       H  nX   X   :w  d  M    O   US:  a  US-  nSU S3/nXS n XS n[	        U 5      [	        U5      :X  aJ  [        [	        U 5      5       H  nX*    X*    :w  d  M    O   US:  a  US-  nUSU S	3/-  nU SU*  n USU*  nS
nU R                  5       (       d  UR                  5       (       a.  [        [        U 5      5      n [        [        U5      5      nUS/-  nUU" UR                  U5      U R                  U5      5       Vs/ s H  nUR                  S5      PM     sn-  nU$ s  snf )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*   )
difflibr   rangeminrB   isspacereprr"   
splitlinesstrip)r   r   r   r   r.   ikeependsrF   s           r   r   r     s    K{s3t9c%j12Aw%(" 3 r6GAA3STK 8D"IEt9E
"3t9%8uRy( & 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                t   US::  a  [        5       (       d  S/$ SS Kn[        5       R                  U 5      R	                  5       n[        5       R                  U5      R	                  5       nSS/nUR                  U" SR                  S UR                  Xe5       5       5      SS9R	                  5       5        U$ )	Nr   zUse -v to get more diffr3   z
Full diff:r*   c              3  B   #    U  H  nUR                  5       v   M     g 7frJ   )rstrip).0rF   s     r   	<genexpr>'_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     !|MOO)**#o--d3>>@O$..u5@@B|$K II #MM*:L  	
 *, r    c                N   [        U [        5      =(       a    [        U[        5      n/ n[        U 5      n[        U5      n[        [	        Xg5      5       He  nX   X   :w  d  M  U(       a  XUS-    n	XUS-    n
OX   n	X   n
UR                  SU SU" [        U	5      5       SU" [        U
5      5       35          O   U(       a  U$ Xg-
  nU(       aT  US:  a  Sn[        X   5      nOSU-
  nSn[        X   5      nUS:X  a  UU SU" U5       3/-  nU$ US	XU" U5      4-  /-  nU$ )
Nr4   z	At index z diff:  != r   LeftRightz contains one more item: z/%s contains %d more items, first extra item: %s)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   b  ss    !u-J*UE2JOK4yHE
I3x+,7eh "a!e_
#A.!W
#hA3 Z 012${4CT7U6VX + -.  #Ha<"MT_-E8|H#MU_-Eq= /!:;u;M:NO K 	 A K,>?@ K r    c                z    / nUR                  [        SXU5      5        UR                  [        SXU5      5        U$ )Nr   r   )r   _set_one_sided_diffr   r   r   r   r.   s        r   r   r     s?     K*64LM*7EMNr    c                2    [        XU5      nU(       d  S/$ U$ Nrz   )r   r   s        r   r   r     "     #4<K%&&r    c                2    [        XU5      nU(       d  S/$ U$ r   )r   r   s        r   r   r     r   r    c                    [        SXU5      $ )Nr   r   r   r   r   r   s       r   r   r     s     w[AAr    c                    [        SXU5      $ )Nr   r   r   s       r   r   r     s     vtK@@r    c                    / nX-
  nU(       a>  UR                  SU  S35        U H#  nUR                  U" [        U5      5      5        M%     U$ )NzExtra items in the z set:)r;   r   )posnset1set2r   r.   r   items          r   r   r     sR     K;D0e<=D{8D>:; r    c                >   / n[        U 5      n[        U5      nUR                  U5      nU Vs0 s H  oU   X   :X  d  M  XU   _M     n	nU	(       a  US:  a  US[        U	5       S3/-  nO9U	(       a2  US/-  nXB" [        R                  " U	5      5      R                  5       -  nU Vs1 s H  oU   X   :w  d  M  UiM     n
nU
(       aA  US/-  nU
 H5  nUU" [        XU   05      5      S-   U" [        XU   05      5      -   /-  nM7     XV-
  n[        U5      nU(       ai  UR                  SXS:X  a  S	OS
4-  5        UR                  U" [        R                  " U Vs0 s H  oX   _M	     sn5      5      R                  5       5        Xe-
  n[        U5      nU(       ai  UR                  SXS:X  a  S	OS
4-  5        UR                  U" [        R                  " U Vs0 s H  oX   _M	     sn5      5      R                  5       5        U$ s  snf s  snf s  snf s  snf )Nrw   	Omitting ! identical items, use -vv to showzCommon items:zDiffering items:r   zLeft contains %d more item%s:r4   r3   rG   zRight contains %d more item%s:)	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     s5     K4yHE
I""9-F &>1q'UX*=JAAwJD>!)CI;.OPQQ	(({6>>$#78CCEE5v!aEH!4AvD5*++AHaa\23h8}567 K  %J_N+q%8rcBC	
 	J'GJq47
J'GHITTV	
 &K+&O,&:DE	
 	['I[58['IJKVVX	
 G ? 6" (H (Js#   H 	H)H;HHHc                   [        U 5      (       d  / $ [        U 5      (       aD  SS KnUR                  U 5      nU Vs/ s H!  ofR                  (       d  M  UR
                  PM#     nnOk[        U 5      (       a<  U R                  nU Vs/ s H"  n[        US5      (       d  M  UR
                  PM$     nnO[        U 5      (       a  U R                  nO eSn	/ n
/ nU H?  n[        X5      [        X5      :X  a  U
R                  U5        M.  UR                  U5        MA     / nU
(       d  U(       a  US/-  nU
(       a%  US:  a  UR                  S[        U
5       S35        O9U
(       a2  US/-  nX" [        R                  " U
5      5      R                  5       -  nU(       a  US	/-  nX" [        R                  " U5      5      R                  5       -  nU Ho  n[        X5      n[        X5      nUSS
U S3U	 U SU" [!        U5      5       SU" [!        U5      5       3/-  nU[#        XX#5       Vs/ s H  nX-   PM	     sn-  nMq     U$ s  snf s  snf s  snf )Nr   eqr?   r3   rw   r   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute :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     sE    $	 ''-
1;L||9499L	))
3=V:%PTAU:5:::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 -J!%/K6ugQ?(5'KZ0@$A#B${SWXcSdGeFfg K
 +[D  K  W M WDs   III I/Ic                   UR                  U 5      nUS U nX[        U 5      -   S  nXE-   n[        XU5      n[        U SS9 S3/nU Hs  n	U	R	                  S5      (       a  M  U	R	                  S5      (       a  M3  U	R	                  S5      (       a  UR                  SU	SS  -   5        Mb  UR                  U	5        Mu     U$ )	Nr   )rx   z is contained here:Skippingz- z+ r?   rw   )findrB   r   r   rA   r;   )
termtextr   indexheadtailcorrect_textr   newdiffrF   s
             r   r   r   K  s    IIdOE<DD	!#$D;Ld'2D4,--@ABG??:&&??4  ??4  NN4$qr(?+NN4   Nr    c                 .    SS/n [        S U  5       5      $ )z0Check if we're currently running on a CI system.CIBUILD_NUMBERc              3  F   #    U  H  o[         R                  ;   v   M     g 7frJ   )osenviron)r   vars     r   r    running_on_ci.<locals>.<genexpr>a  s     5HSbjj 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  )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   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   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   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     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    