
    ;e3                        	 d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlm	Z	  G d d          Z
 e
            Zej        Zej        Z G d dej                  Z G d	 d
ej                  Z G d d          Z G d d          Z G d dej                  Z G d dej                  Zedk    r ej        d           dS dS )    )calltipN)Mock)Textc                       e Zd Z	 dZddZde_        d Zde_        ddZde_        d	 Zd
e_        d Zde_        ddZ	de	_        d Z
de
_        d Zde_        d Zed             Zed             ZdS )TCz(ai=None, *b)Nc                     d S N selfaibs      5/usr/lib/python3.11/idlelib/idle_test/test_calltip.py__init__zTC.__init__             z(self, ai=None, *b)c                     d S r	   r
   r   s    r   t1zTC.t1   r   r   (self)c                     d S r	   r
   r   s      r   t2zTC.t2   r   r   z(self, ai, b=None)c                     d S r	   r
   )r   r   argss      r   t3zTC.t3   r   r   z(self, ai, *args)c                     d S r	   r
   r   r   s     r   t4zTC.t4   r   r   z(self, *args)c                     d S r	   r
   )r   r   r   r   kws        r   t5zTC.t5   r   r   z(self, ai, b=None, *args, **kw)c                     d S r	   r
   )nor   s     r   t6zTC.t6   r   r   z
(no, self)c                     d S r	   r
   r   cis     r   __call__zTC.__call__   r   r   z
(self, ci)c                     d S r	   r
   r   s    r   ndzTC.nd    r   r   c                     d S r	   r
   )clsas     r   cmzTC.cm"   s    Er   c                     d S r	   r
   )r   s    r   smzTC.sm$       ur   r	   )__name__
__module____qualname__tipr   r   r   r   r   r!   r$   r(   r*   classmethodr.   staticmethodr0   r
   r   r   r   r      s        	
C****(HLBF####!BF""" BFBF0000.BFBF!!!HL [ \r   r   c                   h    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )Get_argspecTestc                 :     fd} G d dt                     } G d d          }|j         ||d|j                     |t           j        d            |t           j        d           d	} |t           j        d
|z               ||j        d
|z               |g j        d|z               |t
          j        d            | |            t                     t          j	        d          } |t          j
        d            ||j
        d           d S )Nc                 N                         t          |           |           d S r	   )assertEqualget_spec)objoutr   s     r   tiptestz.Get_argspecTest.test_builtins.<locals>.tiptest7   s%    Xc]]C00000r   c                       e Zd ZdS )+Get_argspecTest.test_builtins.<locals>.ListN)r2   r3   r4   r
   r   r   ListrB   ;   s          r   rC   c                       e Zd ZdZdS ))Get_argspecTest.test_builtins.<locals>.SBNr2   r3   r4   r(   r
   r   r   SBrE   >   s        d888r   rG   z(iterable=(), /)
zY(*args, **kwargs)
Create and return a new object.  See help(type) for accurate signature.zY(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.z&
Append object to the end of the list.z(self, object, /)z(object, /)z>(function, instance, /)
Create a bound instance method object. aO  (pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl.  repl can be either a string or a callable;
if a string, backslash escapes in it are processed.  If it is
a callable, it's passed the Match object and must returnzm(repl, string, count=0)
Return the string obtained by replacing the leftmost non-overlapping occurrences o...)list__doc____new__r   appendtypes
MethodTypedefault_tiprecompilesub)r   r@   rC   rG   
append_docps   `     r   test_builtinszGet_argspecTest.test_builtins5   s   	1 	1 	1 	1 	1 	'&&&&4&&& 	#"""""""<#GD(( () ) ) 	7	8 	8 	8 	O	P 	P 	P ?
0:=>>>0:=>>>	=:5666 7	8 	8 	8 	k"""JrNN < 	= 	= 	= 	 $ 	% 	% 	% 	% 	%r   c                     t           j        j        /|                     t	          t           j                  d           d S d S )Na6  (width=70, initial_indent='', subsequent_indent='', expand_tabs=True,
    replace_whitespace=True, fix_sentence_endings=False, break_long_words=True,
    drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None,
    placeholder=' [...]')
Object for wrapping/filling text.  The public interface consists of
the wrap() and fill() methods; the other methods are just there for
subclasses to override in order to tweak the default behaviour.
If you want to completely replace the main wrapping algorithm,
you'll probably have to override _wrap_chunks().)textwrapTextWrapperrJ   r<   r=   r   s    r   test_signature_wrapz#Get_argspecTest.test_signature_wrapb   sJ    '3Xh&:;; 	>5 	6 	6 	6 	6 	6 43r   c                 8   dd}dd}dd}t           j        }d|z   dz   }d|z   dz   }d|z   d	z   |z   d
z   }||f||f||ffD ]W\  }}	|                     ||	          5  |                     t	          |          |	           d d d            n# 1 swxY w Y   Xd S )Ndaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac                     d S r	   r
   ss    r   fooz4Get_argspecTest.test_properly_formatted.<locals>.fooq       Dr   c                     	 d S r	   r
   r]   s    r   barz4Get_argspecTest.test_properly_formatted.<locals>.bart   s
    Dr   dbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc                     d S r	   r
   )r^   zs     r   bazz4Get_argspecTest.test_properly_formatted.<locals>.bazx   r`   r   zV(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
zaaaaaaaaaaaaaaaaaaa')z!aaaaaaaaaaaaaaaaaaa')
Hello GuidozRaaaaaaaaaaaaaaaaaaa', z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
z.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'))funcdoc)r[   )r[   rc   )r   _INDENTsubTestr<   r=   )
r   r_   rb   rf   indentsfoosbarsbazrg   rh   s
             r   test_properly_formattedz'Get_argspecTest.test_properly_formattedo   s`   	 	 	 		 	 	 		 	 	 	 24:;>24:;>++24:;>%% (..1** tsDkC;? 	6 	6HD4S11 6 6  $5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6s   $BB	B	c                     d }d|_         |                     t          |          ddt          j        dz
  z  dz               d S )Nc                      d S r	   r
   r
   r   r   fz2Get_argspecTest.test_docline_truncation.<locals>.f   r   r   ,  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()
r-      z...)rJ   r<   r=   r   	_MAX_COLSr   rr   s     r   test_docline_truncationz'Get_argspecTest.test_docline_truncation   sM    	!&PS'2CA2E-F-N&P&PQQQQQr   c                     |                      t          t                    d           |                      t          t                    d           d }d|_        |                      t          |          ddt
          j        z  z              d S )NzFrange(stop) -> range object
range(start, stop[, step]) -> range objectzbytes(iterable_of_ints) -> bytes
bytes(string, encoding[, errors]) -> bytes
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
bytes() -> empty bytes objectc                      d S r	   r
   r
   r   r   rr   z3Get_argspecTest.test_multiline_docstring.<locals>.f   r   r   za
a
a
a
a
a
a
a
a
a
a
a
a
a
a
()z
a)r<   r=   rangebytesrJ   r   
_MAX_LINESrv   s     r   test_multiline_docstringz(Get_argspecTest.test_multiline_docstring   s    %=	> 	> 	>
 	% +! 	" 	" 	" 		!dUW5G-G&GHHHHHr   c                 V   d }d|_         dd}d|_         d }d|_         d }d|_         dd	}d
|_         |j        dnd}|||||t          fD ][}|                     |          5  |                     t          |          |j         |z              d d d            n# 1 swxY w Y   \d S )Nc                      d S r	   r
   r
   r   r   r   z*Get_argspecTest.test_functions.<locals>.t1   r   r   rz   c                     d S r	   r
   )r-   r   s     r   r   z*Get_argspecTest.test_functions.<locals>.t2   r   r   z(a, b=None)c                     d S r	   r
   )r-   r   s     r   r   z*Get_argspecTest.test_functions.<locals>.t3   r   r   z
(a, *args)c                      d S r	   r
   r   s    r   r   z*Get_argspecTest.test_functions.<locals>.t4   r   r   (*args)c                     d S r	   r
   )r-   r   r   r    s       r   r!   z*Get_argspecTest.test_functions.<locals>.t5   r   r   z(a, b=None, *args, **kw)
docrH   )rg   r	   )r5   rJ   r   rj   r<   r=   )r   r   r   r   r   r!   rh   rg   s           r   test_functionszGet_argspecTest.test_functions   s-       ----+/ggRRR, 	A 	AD4(( A A  $C@@@A A A A A A A A A A A A A A A	A 	As   %,BB!	$B!	c                 <   t           j        dnd}t           j        t           j        t           j        t           j        t           j        t           j        t           j        fD ][}| 	                    |          5  | 
                    t          |          |j        |z              d d d            n# 1 swxY w Y   \| 
                    t          t           j                  d|z              | 
                    t          t           j                  d|z              d S )Nr   rH   )meth(a)z(b))r   rJ   r   r   r   r   r!   r$   r(   rj   r<   r=   r5   r.   r0   )r   rh   r   s      r   test_methodszGet_argspecTest.test_methods   s'   /ggRUBE25"%r{K 	A 	AD4(( A A  $C@@@A A A A A A A A A A A A A A A"%%#+666"%%#+66666s   8,B00B4	7B4	c                 r   t           j        dnd}t          j        dft          j        dft          j        dft          j        dft          dft           j        dffD ]Z\  }}|                     ||          5  | 	                    t          |          ||z              d d d            n# 1 swxY w Y   [d S )	Nr   rH   rz   r   r   (ci)r   r   mtip)r   rJ   tcr   r   r$   r(   r.   rj   r<   r=   )r   rh   r   r   s       r   test_bound_methodsz"Get_argspecTest.test_bound_methods   s    /ggRUDMBE9+=UH-V/DL25%.; 	= 	=JD$ 4d33 = =  $<<<= = = = = = = = = = = = = = =	= 	=s   8'B++B/	2B/	c                     G d d          } |            }|j         df|j         dffD ]W\  }}|                     ||          5  |                     t          |          |           d d d            n# 1 swxY w Y   Xd S )Nc                       e Zd Zd ZdS )1Get_argspecTest.test_starred_parameter.<locals>.Cc                      d S r	   r
   r   s    r   m1z4Get_argspecTest.test_starred_parameter.<locals>.C.m1   r   r   N)r2   r3   r4   r   r
   r   r   Cr      s        r   r   r   r   )r   rj   r<   r=   )r   r   cr   r   s        r   test_starred_parameterz&Get_argspecTest.test_starred_parameter   s    	  	  	  	  	  	  	  	 ACCT9-i/@B 	7 	7JD$4d33 7 7  $6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   $A66A:	=A:	c                     G d d          } G d d          }t           j        }|                     t           |            j                  |           |                     t           |                      |           d S )Nc                       e Zd Zd ZdS )7Get_argspecTest.test_invalid_method_get_spec.<locals>.Cc                      d S r	   r
   )kwargss    r   m2z:Get_argspecTest.test_invalid_method_get_spec.<locals>.C.m2   r   r   N)r2   r3   r4   r   r
   r   r   r   r      s        """""r   r   c                       e Zd Zd ZdS ):Get_argspecTest.test_invalid_method_get_spec.<locals>.Testc                     d S r	   r
   )r-   s    r   r(   zCGet_argspecTest.test_invalid_method_get_spec.<locals>.Test.__call__   r   r   NrF   r
   r   r   Testr      s        $$$$$r   r   )r   _invalid_methodr<   r=   r   )r   r   r   r   s       r   test_invalid_method_get_specz,Get_argspecTest.test_invalid_method_get_spec   s    	# 	# 	# 	# 	# 	# 	# 	#	% 	% 	% 	% 	% 	% 	% 	% &!!##&))4000$$&&))400000r   c                 
    d}d S )Nu   (AΑАאاअḀあ, a)r
   )r   unis     r   test_non_ascii_namez#Get_argspecTest.test_non_ascii_name   s     Ar   c                     t           j        dft          j        dffD ]W\  }}|                     ||          5  |                     t          |          |           d d d            n# 1 swxY w Y   Xd S )Nr   rz   r   )r   r*   r   rj   r<   r=   )r   r   r   s      r   test_no_docstringz!Get_argspecTest.test_no_docstring   s    E8,rudm< 	7 	7JD$4d33 7 7  $6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   $A))A-	0A-	c                 n    G d d          } G d d|          } G d d|          }|t           f|t           f |            df |            df |            d	ffD ]W\  }}|                     ||
          5  |                     t          |          |           d d d            n# 1 swxY w Y   Xd S )Nc                       e Zd Zd ZdS )8Get_argspecTest.test_buggy_getattr_class.<locals>.NoCallc                     t           r	   )
IndexError)r   names     r   __getattr__zDGet_argspecTest.test_buggy_getattr_class.<locals>.NoCall.__getattr__   s      r   N)r2   r3   r4   r   r
   r   r   NoCallr      s#        ! ! ! ! !r   r   c                       e Zd Zd ZdS )7Get_argspecTest.test_buggy_getattr_class.<locals>.CallAc                     d S r	   r
   r&   s     r   r(   z@Get_argspecTest.test_buggy_getattr_class.<locals>.CallA.__call__       r   NrF   r
   r   r   CallAr      #            r   r   c                       e Zd Zd ZdS )7Get_argspecTest.test_buggy_getattr_class.<locals>.CallBc                     d S r	   r
   )ouir-   r   r   s       r   r(   z@Get_argspecTest.test_buggy_getattr_class.<locals>.CallB.__call__   r   r   NrF   r
   r   r   CallBr      r   r   r   rH   r   z	(a, b, c)r   )rO   rj   r<   r=   )r   r   r   r   r   r   s         r   test_buggy_getattr_classz(Get_argspecTest.test_buggy_getattr_class   s`   	! 	! 	! 	! 	! 	! 	! 	!	 	 	 	 	F 	 	 		 	 	 	 	F 	 	 	 $[1E;3G#VXXrNUUWWf,="UWWk24 	7 	7JD$ 4d33 7 7  $6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   9$B))B-	0B-	c                 N    G d dt                     } G d d|          }|t          t                     f|t          f |            dffD ]W\  }}|                     ||          5  |                     t          |          |           d d d            n# 1 swxY w Y   Xd S )Nc                   :    e Zd Z ei j        i j                  ZdS )2Get_argspecTest.test_metaclass_class.<locals>.TypeN)r2   r3   r4   property__getitem____setitem__	__class__r
   r   r   Typer      s#         @@IIIr   r   c                       e Zd ZdZdS )4Get_argspecTest.test_metaclass_class.<locals>.Objectr   N)r2   r3   r4   	__slots__r
   r   r   Objectr      s        #IIIr   r   )	metaclassrH   r   )typer=   rO   rj   r<   )r   r   r   r   r   s        r   test_metaclass_classz$Get_argspecTest.test_metaclass_class   s,   	A 	A 	A 	A 	A4 	A 	A 	A	$ 	$ 	$ 	$ 	$t 	$ 	$ 	$ 	$!8D>>2V[4I#VXXrN, 	7 	7JD$4d33 7 7  $6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s   )$BB	 B	c                     ddddg i fD ]S}|                      |          5  |                     t          |          d           d d d            n# 1 swxY w Y   Td S )Nr   g        0   0)r>   rH   )rj   r<   r=   )r   r>   s     r   test_non_callablesz"Get_argspecTest.test_non_callables   s    sCr2. 	4 	4C#&& 4 4  #3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s   $AA	A	N)r2   r3   r4   rU   rY   ro   rw   r~   r   r   r   r   r   r   r   r   r   r   r
   r   r   r9   r9   -   s        +% +% +%Z6 6 66 6 6<R R R
I I I&A A A"7 7 7= = =7 7 71 1 1: : :7 7 7
7 7 7"7 7 74 4 4 4 4r   r9   c                       e Zd Zd Zd ZdS )Get_entityTestc                 T    |                      t          j        d                     d S )Nz1/0)assertIsNoner   
get_entityr   s    r   test_bad_entityzGet_entityTest.test_bad_entity  s'    ',U3344444r   c                 `    |                      t          j        d          t                     d S )Nint)assertIsr   r   r   r   s    r   test_good_entityzGet_entityTest.test_good_entity	  s'    g(//55555r   N)r2   r3   r4   r   r   r
   r   r   r   r     s2        5 5 56 6 6 6 6r   r   c                       e Zd Z	 d ZdS )
mock_Shellc                 h    t          d           |_        || _        d| _        d| _        d| _        d S )N)return_valuez>>>       )r   tag_prevrangetextprompt_last_lineindentwidthtabwidth)r   r   s     r   r   zmock_Shell.__init__  s7    !t444	 &r   N)r2   r3   r4   r   r
   r   r   r   r     s&        4    r   r   c                       e Zd Zd Zd ZdS )mock_TipWindowc                     d S r	   r
   r   s    r   r   zmock_TipWindow.__init__  s    r   c                     ||f| _         t          t          |                    d                    \  | _        | _        d S )N.)r   mapr   split	parenlineparencol)r   r   	parenleft
parenrights       r   showtipzmock_TipWindow.showtip  s6    z)	(+C1E1E(F(F%r   N)r2   r3   r4   r   r   r
   r   r   r   r     s7          G G G G Gr   r   c                   "    e Zd Zd ZddZd ZdS )WrappedCalltipc                     t                      S r	   )r   r   s    r   _make_tk_calltip_windowz&WrappedCalltip._make_tk_calltip_window%  s    r   Nc                 F    | j         rd | _         | xj        dz  c_        d S d S )N   )active_calltiptips_removed)r   events     r   remove_calltip_windowz$WrappedCalltip.remove_calltip_window(  s9     	#"&D"	# 	#r   c                     dS )Nr5   r
   )r   
expressions     r   	fetch_tipzWrappedCalltip.fetch_tip-  r1   r   r	   )r2   r3   r4   r   r   r   r
   r   r   r   r   $  sF             # # # #
    r   r   c                   H    e Zd Zed             Zd Zd Zd Zd Zd Z	d Z
dS )	CalltipTestc                 x    t                      | _        t          t          | j                            | _        d S r	   )r   r   r   r   ct)r,   s    r   
setUpClasszCalltipTest.setUpClass3  s*    66
38 4 455r   c                 l    | j                             dd           d | j        _        d| j        _        d S )Nz1.0endr   )r   deleter  r   r   r   s    r   setUpzCalltipTest.setUp8  s4    	&&&!% r   c                 .   | j         j        }| j                            dd            |d           | j         j        | _         ||            | j                            dd            |d           |                     | j         j        d            d S )Ng      ?zf(Finsert))r  open_calltipr   r  r   r5   r   )r   testfuncopentips      r   
open_closezCalltipTest.open_close>  s    '&	d###7)	3'''$'0$77777r   c                 6    d }|                      |           d S )Nc                 F    |                      | j        j        d           d S )N)z1.1z1.end)r<   r5   r   r   s    r   r   z)CalltipTest.test_open_close.<locals>.argsJ  s#    TX],<=====r   r  r   s     r   test_open_closezCalltipTest.test_open_closeI  s)    	> 	> 	>r   c                 6    d }|                      |           d S )Nc                     dD ]Q}| j                             dd           | j                            d           | j                            d           R|                     | j        j        | j                   d S )Nabcr  r-   T)r   r  r  r  r   r   r5   r   chars     r   forcez.CalltipTest.test_repeated_force.<locals>.forceO  sy     + +	  3///$$T***$$T****MM$'0$(;;;;;r   r  )r   r  s     r   test_repeated_forcezCalltipTest.test_repeated_forceN  s+    	< 	< 	< 	r   c                 6    d }|                      |           d S )Nc                 b   dD ]}|                      |          5  | j                            d|           dD ]}| j                            d|           |                     | j        j        | j                   d d d            n# 1 swxY w Y   | j                            dd           d S )N)r-   ')contextr  (()())r  )rj   r   r  r   r  r   r5   )r   r  r  s      r   parensz0CalltipTest.test_repeated_parens.<locals>.parensX  s   # D D\\'\22 D DI$$Xw777 ( 9 9	((48888MM$'"8$(CCC	D D D D D D D D D D D D D D D
 IXs+++++s   A!BB	B	r  )r   r!  s     r   test_repeated_parensz CalltipTest.test_repeated_parensW  s+    	, 	, 	, 	r   c                 6    d }|                      |           d S )Nc                     | j                             dd           dD ]}| j                             d|           |                     | j        j        | j                   | j                             dd           d S )Nr  z# r   
)r   r  r   r  r   r5   r  s     r   commentz0CalltipTest.test_comment_parens.<locals>.commentc  s}    IXt,,,  1 1	  40000MM$'0$(;;;IXt,,,,,r   r  )r   r&  s     r   test_comment_parenszCalltipTest.test_comment_parensb  s+    	- 	- 	- 	     r   N)r2   r3   r4   r6   r  r	  r  r  r  r"  r'  r
   r   r   r  r  1  s        6 6 [6! ! !	8 	8 	8  
  	  	  	 ! ! ! ! !r   r  __main__   )	verbosity)idlelibr   unittestunittest.mockr   rW   rM   rP   idlelib.idle_test.mock_tkr   r   r   _default_callable_argspecrO   get_argspecr=   TestCaser9   r   r   r   Calltipr   r  r2   mainr
   r   r   <module>r4     s                   				 * * * * * *       6 RTT/V4 V4 V4 V4 V4h' V4 V4 V4r6 6 6 6 6X& 6 6 6       G G G G G G G G
 
 
 
 
W_ 
 
 
8! 8! 8! 8! 8!(# 8! 8! 8!v zHMA r   