
    F-PhP                    6   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!dWdXd Z"dYd"Z#dZd$Z$d[d'Z%d\d+Z&d\d,Z'd\d-Z(d\d.Z)d]d0Z*d]d1Z+d]d2Z,d]d3Z-d^d5Z.	 d_d`d<Z/	 dadbd@Z0	 dadcdAZ1	 dadddCZ2	 dadedEZ3	 dadfdGZ4	 dadfdHZ5	 dadfdIZ6	 dadfdJZ7	 dadfdKZ8dgdOZ9	 dadhdQZ:dbdRZ;dadidUZ<djdVZ=dS )kz"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dS )_HighlightFuncpythonsourcestrlexerLiteral['diff', 'python']returnc                    dS )z'Apply highlighting to the given source.N )selfr   r   s      V/var/www/html/test/jupyter/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   r   r   r   r   r   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"   explanationc                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_explanationr2   6   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_linesr0   valuess       r    r-   r-   E   s     "))$//Iq\NEABB- ( ( 	(fQi#777LL    "III'IIIILr"   r0   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.
    Nr6   r   r7   r;   zand   zwhere z +  r8   )r9   r:   r9   )list
startswithr=   lenpop)r0   r1   stackstackcntlinesindents          r    r.   r.   V   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   rL   s    r    
issequencerT   y   s)    a122M:a;M;M7MMr"   c                ,    t          | t                    S rO   )rP   r   rS   s    r    istextrV   }   s    ar"   c                ,    t          | t                    S rO   )rP   dictrS   s    r    isdictrY      s    ar"   c                :    t          | t          t          f          S rO   )rP   set	frozensetrS   s    r    issetr]      s    a#y)***r"   objc                R    t          | t                    ot          | dd           d uS )N_fields)rP   tuplegetattrr^   s    r    isnamedtuplerd      s(    c5!!Ogc9d&C&C4&OOr"   c                (    t          | dd           d uS )N__dataclass_fields__rb   rc   s    r    	isdataclsrh      s    3.55TAAr"   c                (    t          | dd           d uS )N__attrs_attrs__rg   rc   s    r    isattrsrk      s    3)400<<r"   c                d    	 t          |            t          |            S # t          $ r Y dS w xY w)NF)iterrV   	Exceptionrc   s    r    
isiterablero      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 z<string>T)hasattr__eq__rr   rs   rk   )r^   code_filenames     r    has_default_eqrw      sd     sz:&& +73:3F+V+V +
+73<< 	7%66
**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.NFDr6   )r{   A      )maxsizer{    Nz==znot inz!=Both sets are equalz>=z<=r:   <z<(pytest_assertion plugin: representation of details failed: .z+ Probably an object has a faulty __repr__.)r   r5   )get_verbosityr   VERBOSITY_ASSERTIONSrP   r   r   r   rE   r   get_terminal_writer
_highlight_compare_eq_anyrV   _notin_textr]   _compare_gte_set_compare_lte_set_compare_gt_set_compare_lt_setr   Exitrn   _pytest_codeExceptionInfofrom_current_getreprcrash)configrx   ry   rz   r{   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)rV   
_diff_text_pytest.python_apir   rP   _repr_comparetyperh   rk   rd   _compare_eq_clsrT   _compare_eq_sequencer]   _compare_eq_setrY   _compare_eq_dictro   _compare_eq_iterableextend)	ry   rz   r   r   r*   r   approx_side
other_sideexpls	            r    r   r      s    Kd|| %u % uk7CC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  ||
                    |          | 
                    |                    D                       d          
                                           |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   )ndiffr6   *   
   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   | ]}|                     d           V  dS )r,   N)strip.0rI   s     r    	<genexpr>z_diff_text.<locals>.<genexpr>J  sB         

4       r"   diffr   )difflibr   rangeminrE   isspacereprr   r   r/   
splitlines)ry   rz   r   r   r   r*   ikeependss           r    r   r     sS    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 II  !E%"2"28"<"<dooh>W>WXX     	
 	
 	
 *,,   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 diffr5   z
Full diff:r,   c              3  >   K   | ]}|                                 V  d S rO   )rstripr   s     r    r   z'_compare_eq_iterable.<locals>.<genexpr>g  s>              r"   r   r   )running_on_cir   r   pformatr   r   r/   r   )ry   rz   r   r   r   left_formattingright_formattingr*   s           r    r   r   T  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
  }|rl|dk    rd}t          | |                   }nd|z
  }d}t          ||                   }|dk    r|| d ||           gz  }n|| d	| d
 ||           gz  }|S )Nr6   z	At index z diff:  != r   LeftRightz contains one more item: z
 contains z more items, first extra item: )rP   bytesrE   r   r   r=   r   r   )ry   rz   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*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  iiHiiU`U`afUgUgii K r"   AbstractSet[Any]c                    g }|                     t          d| ||                     |                     t          d|| |                     |S )Nry   rz   )r   _set_one_sided_diffry   rz   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 )Nrz   r   ry   rz   r   r   s       r    r   r     s     wt[AAAr"   c                &    t          d| ||          S )Nry   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:)r=   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          |          }|rr|                    d	| d
|dk    rdnd d           |                     |t          j         fd|D                                                                            ||z
  }t          |          }|rr|                    d| d
|dk    rdnd d           |                     |t          j        fd|D                                                                            |S )Nc                F    i | ]}|         |         k    ||         S r   r   r   kry   rz   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 z
 more itemr6   r5   rJ   :c                "    i | ]}||         S r   r   )r   r   ry   s     r    r   z$_compare_eq_dict.<locals>.<dictcomp>  s    'G'G'Gq47'G'G'Gr"   zRight contains c                "    i | ]}||         S r   r   )r   r   rz   s     r    r   z$_compare_eq_dict.<locals>.<dictcomp>  s    'I'I'I58'I'I'Ir"   )	r[   intersectionrE   pprintr   r   r   r=   r   )ry   rz   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=P=PrrVY\\\	
 	
 	
 	K'G'G'G'GJ'G'G'GHHIITTVV	
 	
 	
 h&K+&&O 
_o__RS?S?SY\___	
 	
 	
 	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    
<listcomp>z#_compare_eq_cls.<locals>.<listcomp>)  s!    LLLt|L49LLLr"   c                <    g | ]}t          |d           |j        S )eq)rb   r  )r   fields     r    r  z#_compare_eq_cls.<locals>.<listcomp>,  s*    VVV%PTAUAUV5:VVVr"   FrB   r5   r   r   r   zMatching attributes:zDiffering attributes:z$Drill down into differing attribute r   z: r   c                    g | ]}|z   S r   r   )r   rI   rK   s     r    r  z#_compare_eq_cls.<locals>.<listcomp>N  s-          r"   )rw   rh   dataclassesfieldsrk   rj   rd   r`   rb   r=   rE   r   r   r   r   r   )ry   rz   r   r   r	  
all_fieldsfields_to_checkr   r   r  r*   
field_leftfield_rightrK   s                @r    r   r      s    $ 	  ''--
LLLLL	 )
VV:VVV	d		 ,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          |          }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+ rB   r   )findrE   r   r)   r   rD   r=   )
r  r  r   indexheadtailcorrect_textr   newdiffrI   s
             r    r   r   W  s    IIdOOE<DD		!##$D$;LdL*;WEED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 rO   )osenviron)r   vars     r    r   z running_on_ci.<locals>.<genexpr>m  s)      55Ssbj 555555r"   )any)env_varss    r    r   r   j  s)    n%H55H555555r"   r#   r$   )r*   r   r   r   )r*   r   r   r3   )r0   r@   r   r3   )rL   r	   r   rM   )r^   r	   r   rM   )r^   rp   r   rM   )F)
rx   r   ry   r	   rz   r	   r{   rM   r   r|   )r   )
ry   r	   rz   r	   r   r   r   r   r   r3   )
ry   r   rz   r   r   r   r   r   r   r3   )
ry   r   rz   r   r   r   r   r   r   r3   )
ry   r   rz   r   r   r   r   r   r   r3   )
ry   r   rz   r   r   r   r   r   r   r3   )
r   r   r   r   r   r   r   r   r   r3   )
ry   r   rz   r   r   r   r   r   r   r3   )r  r   r  r   r   r   r   r3   )r   rM   )>__doc__
__future__r   collections.abcrQ   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)   r2   r-   r.   rT   rV   rY   r]   rd   rh   rk   ro   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r    <module>r-     s   ( ( ( " " " " " "     $ $ $ $ $ $ $ $ $ $ $ $ # # # # # # $ $ $ $ $ $ . . . . . . 				                    ! ! ! ! ! !           , , , , , , ) ) ) ) ) ) 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" " " " "L HI4 4 4 4 4v 	    B 	9 9 9 9 9@ 		 	 	 	 	  		 	 	 	 	  		 	 	 	 	  	B B B B B 	A A A A A   & 	+ + + + +\4 4 4 4n    &6 6 6 6 6 6r"   