Format: application/x-python-code
⬇ Download File (54.0 KB)
   1  o
   2  
   3  ��hl	�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
   4  Z
   5  ddlmZddl
   6  mZddlmZddlmZmZdd	lmZdd
   7  lmZddlmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%dd
   8  l&m'Z'e
   9  de(fdd��Z)dd�Z*dd�Z+e
  10  dd��Z,e
  11  de-fdd��Z.e
  12  dd��Z/ej0dkr�gd�Z1ngd�Z1ej2�3de1�d d!��Z4d"d#�Z5d$d%�Z6Gd&d'�d'�Z7Gd(d)�d)�Z8Gd*d+�d+ej9�Z:ej2�3d,gd-��d.d/��Z;ej2j<d0d1�ej2�3d2gd3��d4d5���Z=ej2�3d6d7d8d9d:gd;gfd7d<d;gd9d=gfd>d?d9gd;gfd>d@d9gd;gfdAdBd9gd;gfg�dCdD��Z>ej2�3dEgdF��dGdH��Z?ej2�3dIdJdJgdKdKgdLdLgdMdMgdNdNgdOdOgdPdPgdQdgdRdgdSdgdTdUgdVdUgdWdPgdXdYgdZdgd[d[gd\d\gd]d]gd^dgd_dgg�d`da��Z@dS)bz/Tests for the IPython tab-completion machinery.�N)�version)�contextmanager)�Config)�get_ipython)�	completer)�TemporaryDirectory�TemporaryWorkingDirectory)�complete_object)�
  13  decorators)�
  14  latex_symbols)
  15  �
  16  Completion�provisionalcompleter�match_dict_keys�_deduplicate_completions� _match_number_in_dict_key_prefix�completion_matcher�SimpleCompletion�CompletionContext�_unicode_name_compute�_UNICODE_RANGES)�parse�statusccs2�t�j}z|j}||_dVW||_dS||_w�N�r�	Completer�use_jedi)rr�old�r�Wc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_completer.py�jedi_status*s�rc	s�ddl�ddl}g}tdd�D]}z	|�t|��Wn	ty#Yqw|�|�q�fdd�}t||��}g}g}d\}}|D],\}	}
  17  |�|
  18  |	�|�|	|t|d�t|	�t	|	|dd	��d
  19  �f�|	|
  20  }}q@t
  21  |�dS)z�
  22      utility to recompute the largest unicode range without any characters
  23  
  24      use to recompute the gap in the global _UNICODE_RANGES of completer.py
  25      rN�c3sF���t|�dd��D]\}}t|�}|dd|ddfVqdS)NcSs|d|dS)N�rr)�pairrrr�<lambda>Lsz:recompute_unicode_ranges.<locals>.ranges.<locals>.<lambda>rr!�����)�groupby�	enumerate�list)�i�a�b��	itertoolsrr�rangesKs
  26  ��z(recompute_unicode_ranges.<locals>.ranges)rrr!i��d�%r$)r,�unicodedata�range�name�chr�
  27  ValueError�appendr'�hex�round�sorted)r0Zvalid�cr-ZrgZlensZgap_lensZ_pstartZpstop�start�stoprr+r�recompute_unicode_ranges:s4�
  28  ��r<c	Cs�tdg�}tt�}t|�}t|�}d}||ks|dkr:t�\}}}}d|�d|�d|�d|�d|�d	|�d
  29  |�d�}||ksBJ|��|dksJJ|��dS)
  30  zz
  31      Test that the ranges we test for unicode names give the same number of
  32      results than testing the full length.
  33      )rr Ni�z�_UNICODE_RANGES likely wrong and need updating. This is
  34          likely due to a new release of Python. We've find that the biggest gap
  35          in unicode characters has reduces in size to be z characters
  36          (z), from z, to zH. In completer.py likely update to
  37  
  38              _UNICODE_RANGES = [(32, z), (zS, 0xe01f0)]
  39  
  40          And update the assertion below to use
  41  
  42              len_exp <= z	
  43          i41)rr�lenr<)	�
  44  expected_list�testZlen_expZlen_test�message�sizer:r;Zprctrrr�test_unicode_rangecs0
  45  ������	�rBccs8�t�}|jj}zd|j_dVW||j_dS||j_w)NT)rrZgreedy)�ipZgreedy_originalrrr�greedy_completion���rD�
  46  evaluationccs8�t�}|jj}z||j_dVW||j_dS||j_wr)rrrF)rFrCZevaluation_originalrrr�evaluation_policy�rErGccs>�t�}z|jj�|�dVW|jj��dS|jj��wr)rr�custom_matchers�extend�clear)ZmatchersrCrrrrH�s�rH�win32)��abcrM)� abcz" abc")�a bcz"a bc")�a  bcz"a  bc")�  bcz"  bc")rL)rNz\ abc)rOza\ bc)rPza\ \ bc)rQz\ \ bc)za(bcza\(bc)za)bcza\)bc)za( )bcz	a\(\ \)bc)za[1]bcza\[1\]bc)za{1}bcza\{1\}bc)za#bcza\#bc)za?bcza\?bc)za=bcza\=bc)za\bcza\\bc)za|bcza\|bc)za;bcza\;bc)za:bcza\:bc)za'bcza\'bc)za*bcza\*bc)za"bcza\"bc)za^bcza\^bc)za&bcza\&bczs1,expectedcCst�|�|ks	J�dSr)rZprotect_filename)�s1�expectedrrr�test_protect_filename�srTcCs<|D]\}}}t|�}||}|�||�}||ksJ�qdSr)r=Z
  47  split_line)�splitterZ
  48  test_specsZpart1Zpart2�split�
  49  cursor_pos�line�outrrr�check_line_split�s�rZcCs2t��}gd�}t||�t|dd�|D��dS)z,Basic line splitter test with default specs.)	)zrun some/script�zsome/script)zrun scripts/erz
  50  ror.py foo�
  51  scripts/er)z	echo $HOMr[ZHOM)zprint sys.par[�sys.pa)zprint(sys.par[r])zexecfile('scripts/err[r\)�a[x.r[�x.)r^�yr_)zcd "some_file/r[z
  52  some_file/cSsg|]}tt|��qSr)�map�str)�.0�prrr�
  53  <listcomp>�sz#test_line_split.<locals>.<listcomp>N)r�CompletionSplitterrZ)�sp�trrr�test_line_split�s
  54  ric@s$eZdZiZdd�Zedd��ZdS)�NamedInstanceClasscCs||j|<dSr)�	instances)�selfr2rrr�__init__�szNamedInstanceClass.__init__cCs
  55  |j��Sr)rk�keys)�clsrrr�_ipython_key_completions_��
  56  z,NamedInstanceClass._ipython_key_completions_N)�__name__�
  57  __module__�__qualname__rkrm�classmethodrprrrrrj�s
  58  rjc@seZdZddd�Zdd�ZdS)�KeyCompletablercCs
  59  ||_dSr)�things)rlrwrrrrm��
  60  zKeyCompletable.__init__cCs
  61  t|j�Sr)r'rw�rlrrrrp�rxz(KeyCompletable._ipython_key_completions_N)r)rrrsrtrmrprrrrrv�s
  62  rvc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
  63  �Zdd�Zd
  64  d�Z	dd�Z
  65  dd�Zdd�Zdd�Z
  66  dd�Zdd�Zdd�Zdd�Zdd �Zejjejd!kd"d#�d$d%��Zd&d'�Zd(d)�Zejjejjd*vd+d#�d,d-��Zejjejjd*vd+d#�d.d/��Zejjejjd*vd+d#�d0d1��Zejjejjd*vd+d#�d2d3��Z ejje!e"d4��e!d5�kd6d7d8�d9d:��Z#ejjejjd*vd+d#�d;d<��Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*dIdJ�Z+dKdL�Z,dMdN�Z-dOdP�Z.dQdR�Z/dSdT�Z0dUdV�Z1dWdX�Z2dYdZ�Z3d[d\�Z4d]d^�Z5d_d`�Z6dadb�Z7dcdd�Z8dedf�Z9dgdh�Z:didj�Z;dkdl�Z<dmdn�Z=e>�?do�dpdq��Z@e>�?dr�dsdt��ZAdudv�ZBdwdx�ZCdydz�ZDd{d|�ZEd}d~�ZFdd��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPejjejjd*vd+d#�d�d���ZQd�d��ZRd�d��ZSd�S)��
  67  TestCompletercCs|�t�|_|j��dS)z]
  68          We want to silence all PendingDeprecationWarning when testing the completer
  69          N)ZassertWarns�PendingDeprecationWarning�_assertwarns�	__enter__ryrrr�setUpszTestCompleter.setUpcCs,z|j�ddd�WdStyYdSwr)r|�__exit__�AssertionErrorryrrr�tearDowns
  70  �zTestCompleter.tearDowncCs@t�}Gdd�d�}|�|jd<t�|�dd��}|�d�dS)�?Test that errors from custom attribute completers are silenced.c@�eZdZdS)z5TestCompleter.test_custom_completion_error.<locals>.AN�rrrsrtrrrr�A�r��xcSstd��)Nzthis should be silenced)�	TypeError)r)Zexisting_completionsrrr�
  71  complete_Asz>TestCompleter.test_custom_completion_error.<locals>.complete_Ar_N)r�user_nsr	�register�complete)rlrCr�r�rrr�test_custom_completion_error
  72  s
  73  z*TestCompleter.test_custom_completion_errorcCsnt�}|�d�\}}|�d�|�d�ksJ�dd�}|jj�d|�|�d�\}}|�d�|�d	�ks5J�d
  74  S)r��in�input�intcSsddgS)N�example2�example1r)r)rrr�complete_example#szGTestCompleter.test_custom_completion_ordering.<locals>.complete_examplezex*�exr�r�N)rr��indexrZcustom_completersZadd_re)rlrC�_�matchesr�rrr�test_custom_completion_orderingsz-TestCompleter.test_custom_completion_orderingcCsPt�}gd�}|ttt|��D]}|�|�\}}|�|t�|�|t�qdS)N)�ruz%ruzcd /Zfloaz	float(x)/)rr'rarbr�ZassertIsInstance)rlrC�srh�textr�rrr�test_unicode_completions*s�z&TestCompleter.test_unicode_completionscCs�t�}t�tt�d�}|D]}|�|�\}}|�||�|�|t|g�q
  75  |�d�\}}|�|d�|�|dtd�|�d�\}}|�d|�|�d|�dS)N�
  76  zprint(\alphaz\alpharz\alz\aleph)r�random�sampler8rr��assertEqual�assertIn)rlrCrn�kr�r�rrr�test_latex_completions8sz$TestCompleter.test_latex_completionscCs2t�}|j�d�\}}|�|d�|�|d�dS)za
  77          forward latex should really return nothing in either field if nothing is found.
  78          z\really_i_should_match_nothingr[rN)rrZ
  79  latex_matchesr�)rlrCr�r�rrr�test_latex_no_resultsJsz#TestCompleter.test_latex_no_resultscC�&t�}|�d�\}}|�|dg�dS)Nu\βz\beta�rr�r��rlrCr2r�rrr�test_back_latex_completionSsz(TestCompleter.test_back_latex_completioncCr�)Nu\Ⅴ�\ROMAN NUMERAL FIVEr�r�rrr�test_back_unicode_completionZsz*TestCompleter.test_back_unicode_completioncCs4t�}|�d�\}}|�|dg�|�|dg�dS)Nr��Ⅴr�r�rrr�test_forward_unicode_completion`sz-TestCompleter.test_forward_unicode_completioncCs.t��}d|_|�|jd�|�|jd�dS)N� z[\ ])rrf�delimsr�Z_delim_expr)rlrgrrr�test_delim_settinggsz TestCompleter.test_delim_settingcCs$t��}d|_gd�}t||�dS)z%Test with only spaces as split chars.r�))�foor[r�)�run foor[r�)r��barr�N)rrfr�rZ)rlrgrhrrr�test_spacesmszTestCompleter.test_spacescC� dD]}|�t�|�d�qdS)N)�'z'''z'hi' 'r��r�r�has_open_quotes�rlr�rrr�test_has_open_quotes1t��z#TestCompleter.test_has_open_quotes1cCr�)N)�"z"""z"hi" "r�r�r�rrr�test_has_open_quotes2xr�z#TestCompleter.test_has_open_quotes2cC�dD]
  80  }|�t�|��qdS)N)z''z''' '''z'hi' 'ipython'��assertFalserr�r�rrr�test_has_open_quotes3|��z#TestCompleter.test_has_open_quotes3cCr�)N)z""z""" """z"hi" "ipython"r�r�rrr�test_has_open_quotes4�r�z#TestCompleter.test_has_open_quotes4rKz#abspath completions fail on Windows��reasonc	s�t�}t��S}tj�|d��ddg}�fdd�|D�}|D]}t|ddd���q|���d	}|�||�d
  81  �}|��|�d	}�fdd�|D�}|�||�Wd�dS1s\wYdS)Nr��1�2c�g|]}�|�qSrr�rcr���prefixrrre��z?TestCompleter.test_abspath_file_completions.<locals>.<listcomp>�w�utf-8��encodingr!�	a = f("%scr�rrr�r�rrre�r�)	rr�os�path�join�open�closer�r�)	rlrCZtmpdir�suffixes�names�nr9�cmd�comprr�r�test_abspath_file_completions�s"�z+TestCompleter.test_abspath_file_completionscs�t�}t��Rd�ddg}�fdd�|D�}|D]}t|ddd���q|���d	}|�||�d
  82  �}|��|�d	}�fdd�|D�}|�|�t|���Wd�dS1s[wYdS)
  83  Nz./foor�r�cr�rrr�r�rrre�r�z=TestCompleter.test_local_file_completions.<locals>.<listcomp>r�r�r�r!r�csh|]}�|�qSrrr�r�rr�	<setcomp>�r�z<TestCompleter.test_local_file_completions.<locals>.<setcomp>)	rrr�r�r�r��
  84  assertTrue�issubset�set)rlrCr�r�r�r9r�r�rr�r�test_local_file_completions�s"�z)TestCompleter.test_local_file_completionscs�t���fdd�}t��Dd}t|ddd���tjdkr|nd}|d	�d
  85  }|�|j|�|d�d
  86  }|�|j|�|d�d
  87  }|�|j|�Wd�dS1sSwYdS)
  88  Ncs�jjdt|�|d�ddS)Nr)Zcursor_linerW�	full_textzIPCompleter.file_matcher�completions)rZ	_completer=�r��rCrrr��s
  89  ���z5TestCompleter.test_quoted_file_completions.<locals>._zfoo'barr�r�r�rKzfoo\'barz	open('foorz	open("fooz%ls foo)rrr�r��sys�platformr�r�)rlr�r2�escapedr9rr�r�test_quoted_file_completions�s"�z*TestCompleter.test_quoted_file_completions)�alphazParso does not yet parse 3.13c	Cs�t�}|j}|�d�dD]V}t��I||j_|�d�}|dgks'J||f��|�d�}t|�dks8J||f��|�d�}|rJ|ddgksIJ|��n
  90  |d	d
  91  gksTJ|��Wd�n1s^wYq
  92  dS)zr
  93          Make sure the output of `IPCompleter.all_completions` does not have
  94          duplicated prefixes.
  95          zclass TestClass():
  96  	a=1
  97  	a1=2)TFZTestClZ	TestClassz
  98  TestClass.�zTestClass.azTestClass.a1z.az.a1N)rrr�r
  99  r�all_completionsr=)rlrCr9rr�rrr�test_all_completions_dups�s$	
 100  
 101  
 102  
 103  ����z'TestCompleter.test_all_completions_dupscs�t��d�fdd�	}�fdd�}ddl}tdd�|j�d	�dd
 104  �D��}|dkr/|dd
 105  d�|ddd�|ddd�|ddddd�|ddd�dS)z4
 106          A couple of issue we had with Jedi
 107          Ncs�t|�}|dur
 108  |n|}|dur|n|}t��&d�j_t�j�||��}d�j_t|||�|vs5J|��Wd�dS1s@wYdS�NTF�r=r
 109  rrr�r�r)r�r�r�r:�end�lr�r�rr�_test_complete�s"�z/TestCompleter.test_jedi.<locals>._test_completecsnt|�}t��&d�j_t�j�||��}d�j_t|||�|vs%J|��Wd�dS1s0wYdSr�r�)r�r�r�r�r�r�rr�_test_not_complete�s"�z3TestCompleter.test_jedi.<locals>._test_not_completercss�|]}t|�VqdSr)r�)rcr(rrr�	<genexpr>�s�z*TestCompleter.test_jedi.<locals>.<genexpr>�.�)rr�z'jedi >0.9 should complete and not crashza=1;a.�realzcan infer first argumentza=(1,"foo");a[0].zcan infer second argumentza=(1,"foo");a[1].�
 110  capitalizezcover duplicate completionsZim�importr�zdoes not mix types)NN)r�jedi�tuple�__version__rV)rlr�r�r�Zjedi_versionrr�r�	test_jedi�s
 111  "zTestCompleter.test_jedicCszt�}t��d|j_|j�dd�}t|�}d|j_Wd�n1s$wYd|jvs2Jd��d|jvs;Jd��dS)	zp
 112          Lets make sure jedi is capable of pulling out the signature of the function we are completing.
 113          TZoper�FN�filez0Signature of function was not found by completerr�)rr
 114  rrr��next�	signature�rlrCr�r9rrr�test_completion_have_signatures
 115  ��z,TestCompleter.test_completion_have_signaturecCs`t�}t��d|j_|j�dd�}t|�}Wd�n1s wY|jdks.Jd��dS)zB
 116          Lets make sure matchers provide completion type.
 117          Fz%timr�N�magicz+Type of magic was not assigned by completer)rr
 118  rrr�r��typerrrr�test_completions_have_types
 119  �z(TestCompleter.test_completions_have_typer�z0.18.0zKnown failure on jedi<=0.18.0T)r��strictcCs�t�}|�t�d��t��d|j_ttd|j�	dd���}d|j_Wd�n1s-wYt
 120  |�dks>Jd|��|d	jd
 121  ksGJ�dS)zd
 122          Test that completions are correctly deduplicated (even if ranges are not the same)
 123          z.
 124          class Z:
 125              zoo = 1
 126          TzZ.zr�FNr!z1Completions (Z.z<tab>) correctly deduplicate: %s rZzoo)rr��textwrap�dedentr
 127  rrr'rr�r=r�)rlrCr�rrr�test_deduplicate_completions*s	���
 128  �z*TestCompleter.test_deduplicate_completionsc
 129  s
 130  t����d���d��jddd�\}}��d|vd|���fdd	�}t��Q|dd
 131  ddtd
 132  d
 133  d��|d
 134  dddtd
 135  dd��|ddddtd
 136  dd��|ddddtddd��|ddddtddd ��|d!d"d#d$td%d"d&��Wd'�d'S1s~wYd'S)(a-
 137          Test the capability of the Greedy completer.
 138  
 139          Most of the test here does not really show off the greedy completer, for proof
 140          each of the text below now pass with Jedi. The greedy completer is capable of more.
 141  
 142          See the :any:`test_dict_key_completion_contexts`
 143  
 144          za=list(range(5))zd = {'a b': str}r�za[0].)rXz.realz$Shouldn't have completed on a[0]: %sc
 145  s�t��at��Ed�j_�jd||d�\}}��||||�d�j_t���j�||�}Wd�n1s8wY��|t|��Wd�n1sOwYWd�dSWd�dS1sgwYdS)NFr�)rXrWT)rDr
 146  rrr�r�r�r')rXrW�expectr@�
 147  completionr�r9r��rCrlrrr�Zs�P�z0TestCompleter.test_greedy_completions.<locals>._�z"Should have completed on a[0].: %sr�za[0].r�z#Should have completed on a[0].r: %sz
 148  a[0].from_r�z.from_bytesz'Should have completed on a[0].from_: %s�
 149  from_byteszassert str.star�z.startswithz.Should have completed on `assert str.star`: %s��
 150  startswithzd['a b'].str�z.stripz+Should have completed on `d['a b'].str`: %s�	�stripza.app�z.appendz$Should have completed on `a.app`: %sr�r5N)rr�r�r�r
 151  r)rlr�r9rrr�test_greedy_completionsFsd
 152  
 153  
 154  �
 155  �
 156  �
 157  �
 158  �
 159  �"�z%TestCompleter.test_greedy_completionscCs�t�}d|_i|_|j}|�d�t�}d|j_|�|�t	��d|_
 160  |�d�\}}|�d|�|�d|�Wd�n1sAwYt�}d|j_|�|�t	��d|_
 161  |�d�\}}|�
 162  d|�Wd�n1spwYt�}d|j_|�|�t	��d|_
 163  |�d�\}}|�
 164  d|�|�
 165  d|�Wd�n1s�wYt	��d|_
 166  |�d	�\}}|�d
 167  |�Wd�n1s�wY|`|`dS)Nr!zip=get_ipython()rFzip.z.__str__z
 168  ._hidden_attrr�zip._x.z.keys)rZ_hidden_attrZ_xrr�r�IPCompleterZomit__names�
 169  update_configr
 170  rr�r��assertNotIn�rlrCr9�cfgr�r�rrr�test_omit__names�sL
 171  
 172  �
 173  �
 174  ��	zTestCompleter.test_omit__namescCs\t�}|j}d|_|�d�|�d�t�}d|j_|�|�|�d�\}}|�	d|�dS)zV
 175          Limit to all is deprecated, once we remove it this test can go away.
 176          Fz
 177  class D: x=24zd=D()zd.z.xN)
 178  rrrr�rrZlimit_to__all__rr�r�rrrr�test_limit_to__all__False_ok�s
 179  
 180  
 181  z*TestCompleter.test_limit_to__all__False_okcCs,Gdd�d�}t�|��}|�|dg�dS)Nc@seZdZddgZdS)z2TestCompleter.test_get__all__entries_ok.<locals>.Ar�r!N)rrrsrt�__all__rrrrr���r�r��rZget__all__entriesr��rlr��wordsrrr�test_get__all__entries_ok�sz'TestCompleter.test_get__all__entries_okcCs*Gdd�d�}t�|��}|�|g�dS)Nc@r�)z;TestCompleter.test_get__all__entries_no__all__ok.<locals>.ANr�rrrrr��r�r�r r!rrr�"test_get__all__entries_no__all__ok�sz0TestCompleter.test_get__all__entries_no__all__okcCsFt�}|j}d|_|�d�|�d�|�dd�\}}|�d|�dS)NFzlong_variable_name = 1za = []z	a.sort(loZlong_variable_name�rrrr�r�r��rlrCr9r�r�rrr�)test_completes_globals_as_args_of_methods�s
 182  
 183  z7TestCompleter.test_completes_globals_as_args_of_methodscCsLt�}|j}d|_Gdd�d�}|�|jd<|�dd�\}}|�d|�dS)NFc@seZdZdd�ZdS)zSTestCompleter.test_completes_attributes_in_fstring_expressions.<locals>.CustomClasscS�dSrrryrrr�
 184  method_one�sz^TestCompleter.test_completes_attributes_in_fstring_expressions.<locals>.CustomClass.method_oneN)rrrsrtr)rrrr�CustomClass�rr*Z
 185  custom_objzf'{custom_obj.methz.method_one�rrrr�r�r�)rlrCr9r*r�r�rrr�0test_completes_attributes_in_fstring_expressions�sz>TestCompleter.test_completes_attributes_in_fstring_expressionscCslt�}|j}d|_|�d�|�d�|�d�|�dd�\}}|�d|�|�dd�\}}|�d|�dS)	NFzclass Test: passztest_obj = Test()ztest_obj.attribute = 'value'zd = {'key': test_obj.attrz
 186  .attributezd = {'k.e.y': TeZTestr%r&rrr�"test_completes_in_dict_expressionss
 187  
 188  
 189  z0TestCompleter.test_completes_in_dict_expressionscCs�t�}|j}d|_|�d�|�dd�\}}|�d|�|�ddd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d	|�dS)
 190  NFzdef myfunc(a=1,b=2): return a+bz
 191  myfunc(1,bzb=zmyfunc(1,b)r�zmyfunc(a="escaped\")string",bzmin(k, kzkey=r%r&rrr�test_func_kw_completionss
 192  z&TestCompleter.test_func_kw_completionscCs\t�}|j}|�d�}|�|dg�|�d�}|�|gd��|�d�}|�|gd��dS)Nz"min(iterable[, key=func]) -> value�keyz@Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)
 193  )Zncall�resumeZnsplitzB
 194   Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)
 195  )rrZ!_default_arguments_from_docstringr�)rlrCr9Zkwdrrr�%test_default_arguments_from_docstring#s
 196  ��z3TestCompleter.test_default_arguments_from_docstringcCsHt�}|j}|�dd�\}}|�d|�|�dd�\}}|�d|�dS)NZlsmagz%lsmagicz%lsmag)rrr�r�r&rrr�test_line_magics3szTestCompleter.test_line_magicscCs`ddlm}|dd��}t�}|j}|�dd�\}}|�d|�|�dd�\}}|�d|�dS)Nr)�register_cell_magiccSr(rr�rX�cellrrr�
 197  _foo_cellm>�z2TestCompleter.test_cell_magics.<locals>._foo_cellmZ_foo_cez%%_foo_cellmz	%%_foo_ce)�IPython.core.magicr3rrr�r�)rlr3r6rCr9r�r�rrr�test_cell_magics;s
 198  zTestCompleter.test_cell_magicscCs�ddlm}|dd��}t�}|j}|�dd�\}}|�d|�|�d|�|�dd�\}}|�d|�|�d|�|�dd	�\}}|�d|�|�d|�dS)
 199  Nr)�register_line_cell_magiccSr(rrr4rrr�
 200  _bar_cellmMr7z7TestCompleter.test_line_cell_magics.<locals>._bar_cellmZ_bar_cez%_bar_cellmz%%_bar_cellmz%_bar_cez	%%_bar_ce)r8r:rrr�r�r)rlr:r;rCr9r�r�rrr�test_line_cell_magicsJs
 201  z#TestCompleter.test_line_cell_magicscCs.t�}|j}|�d�\}}|�|ddg�dS)NZtimeitz%timeitz%%timeit)rrr�r��rlrCr9r�r�rrr�test_magic_completion_orderbsz)TestCompleter.test_magic_completion_ordercCs|t�}|j}d|_|�d�\}}|�|dg�|�d�|�d�\}}|�|dg�|jd=|�d�\}}|�|dg�dS)NF�mat�%matplotlib�matplotlib = 1Z
 202  matplotlib)rrrr�r��run_cellr�r=rrr�test_magic_completion_shadowingjs
 203  z-TestCompleter.test_magic_completion_shadowingcCsRt�}|j}|�d�\}}|�|dg�|�d�|�d�\}}|�|dg�dS)z�
 204          If the user try to complete a shadowed magic, and explicit % start should
 205          still return the completions.
 206          z%matr@rAN)rrr�r�rBr=rrr�(test_magic_completion_shadowing_explicit~s
 207  z6TestCompleter.test_magic_completion_shadowing_explicitcCslt�}|j}|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�dg|�|�dd�\}}|�dg|�|�dd�\}}|�dg|�|�dd	�\}}|�dg|�|�dd
 208  �\}}|�d|�|�dd�\}}|�d|�|�dd
 209  �\}}|�dg|�|�dd
 210  �\}}|�dg|�dS)N�confz%configZAliasManagerzconfig z%config z
 211  config Aliz%config Alizconfig AliasManagerz%config AliasManagerzconfig AliasManager.zAliasManager.default_aliasesz%config AliasManager.zconfig AliasManager.de�rrr�r�rZassertListEqualr&rrr�test_magic_config�s4zTestCompleter.test_magic_configcCs�t�}|j}|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�d|�|�dd�\}}|�dg|�|�dd�\}}|�dg|�dS)NZcoloz%colorsZNoColorzcolors z%colors zcolors NoCoz%colors NoCorFr&rrr�test_magic_color�s zTestCompleter.test_magic_colorcs�d��fdd�}ddg}||d�ddd	gfksJ�||d
 212  �ddd	gfks&J�||d�ddd	gfks3J�||d
 213  �ddd	gfks@J�||d�dddgfksMJ�||d�dddgfksZJ�||d�dddgfksgJ�||d�dddgfkstJ�gd�}||d�dddgfks�J�||d�dddgfks�J�gd�}||d�dddgfks�J�||d�ddddgfks�J�||d�ddddgfks�J�||d�ddd d!gfks�J�||d"�ddgfks�J�||d#�ddgfks�J�d$S)%z
 214          Test that match_dict_keys works on a couple of use case does return what
 215          expected, and does not crash
 216          � 	
 217  `!@#$^&*()=+[{]}\|;:'",<>?cs&t|d�i|��\}}}||t|�fS)Nr��rr')�args�kwargs�quote�offsetr��r�rr�match�sz1TestCompleter.test_match_dict_keys.<locals>.matchr�sfar�b'r�r�Zfarzb'f�b"r�zb"fr!z'fz"f)�r��W)r�i���
 218  r�)rVr?�33r[r�3333�l�>[=rTi��1999��Z0xdead�
 219  0xdeadbeefr��1111�1234r��21�22Z0b101�0b10101�0b10110Z
 220  a_variablez'' ''Nr)rlrPrnrrOr�test_match_dict_keys�s*z"TestCompleter.test_match_dict_keyscs�d�gd�}dd��fdd�
 221  }||ddd�dd	d
 222  dgfksJ�||ddd�dd	d
 223  dgfks/J�||d
 224  dd�dd	dgfks>J�||ddd�dd	dgfksMJ�||ddd�ddd
 225  gfks\J�||ddd�ddd
 226  gfkskJ�||ddd�ddd
 227  gfkszJ�||ddd�ddd
 228  gfks�J�||ddd�dd	gfks�J�||ddd�dd	gfks�J�ddg}||ddd�dd	dgfks�J�||ddd�dd	dgfks�J�||ddd�dd	dgfks�J�||ddd�dd	gfks�J�gd�}||ddd�dd	d gfks�J�||d!dd�d!d"d#d$gfk�sJ�||dd%d�dd	d
 229  gfk�sJ�||d!d%d�d!d"d&d'gfk�s)J�||dd(d�dd	gfk�s8J�||d)�d!d"d*gfk�sFJ�dS)+z�
 230          Test that match_dict_keys called with extra prefix works on a couple of use case,
 231          does return what expected, and does not crash.
 232          rI)�r�r�)r��oof)r�sbar)�otherr?N)�extracs(t|�|d�|��\}}}||t|�fS)N)r�Zextra_prefixrJ)rhrKrLrMrNr�rOrrrP�s��z7TestCompleter.test_match_dict_keys_tuple.<locals>.matchr�)r�r!r�rfr�z'oz"orQr�rRzb'bzb"b)Zno_foo)�fo)�foo1�foo2�foo3�foo4)rjrkr�rmz'foo)rjrk)rjrkrl)rjrkrlrm)rS)r��2222rU)rVi\rnr[rr^z'2222')rV�'bar'Z4444)rXrWrXr)rlrnrPrrOr�test_match_dict_keys_tuple�s:  
 233  �" " z(TestCompleter.test_match_dict_keys_tuplec	Cs�t�}|jj}d|j_ddddddddd�|jd<|dd�\}}|�d|�|�d|�|�d|�|�d	|�|�d
 234  |�|�d|�|dd�\}}|�d
 235  |�|�d|�|�d|�|�d|�|�d|�|�d|�|�d|�d|j_dS)NT))Zaar)�bbr\rq�cc)�Mr�)�Xr`rt�c�d�d[��line_bufferz'aa', z'bb'z'cc']z77, Z88z99]zd['aa', z11]z'bb', z'bb']z'cc'z'cc', F)rrr�Zauto_close_dict_keysr�r�r�rlrCr�r�r�rrr�!test_dict_key_completion_closuress8�z/TestCompleter.test_dict_key_completion_closurescCsTt�}|jj}ddi|jd<|dd�\}}|�d|�|�d|�|dd�\}}|�d|�|�d	|�|d
 236  d�\}}|�d|�|�d	|�|dd�\}}|�d|�|�d|�|d
 237  d�\}}|�d|�|�d|�|ddd�\}}|�d|�|ddd�\}}|�d|�|�d|�|�d	|�ddddddt�dddddddi|jd<|d
 238  d�\}}|�d|�|�d|�|�d|�|�d|�|�d|�tdd�|D��r�J|��ddddd�|jd<|d
 239  d�\}}|�d|�|�d|�|�d |�|�d!|�td"d�|D���rJ|��|d#d�\}}|�d$|�|d%d�\}}|�d&|�|dd�\}}|�d'|�|d(d�\}}|�d&|�d)|jjj	v�rbd*di|jd<|d+d�\}}|�d*|�d,di|jd<|dd�\}}|�d-|�|�d.|�|�d/|�|�d0|�|�d1|�|d2d�\}}|�d0|�|�d3|�|�d4|�|d5d�\}}|�d0|�|d6d�\}}|�d/|�|d7d�\}}|�d1|�|�d0|�|d8d�\}}|�d1|�|�d0|�|d9d:d�\}}|�d/|�|�d1|�|�d-|�|�d0|�|ddd�\}}|�d0|�td;d�|D���r#J|��|d<dd�\}}|�d0|�td=d�|D���r?J|��|d>d?d�\}}|�d1|�td@d�|D���r[J|��|dAd:d�\}}|�d/|�|�d1|�dBdi|jd<|d7d�\}}|�d1|�|�d0|�|�dC|�|dDd�\}}|�dC|�|�d0|�|�d1|�dS)Ez.Test dictionary key completion for string keysrMNrvrwrx�'abc'�'abc']�d['�abc']zd['azd["zabc"]�d["azd[]r�)ryrWzd['']r��abc'Zabd�badr)�abeN)N�abfr�r�cs��|]}|�d�VqdS�)�]r�r�N��endswith�rc�mrrrr����z@TestCompleter.test_dict_key_completion_string.<locals>.<genexpr>)za
 240  bza'b�a"b�a wordza\nbza\'br�r�csr�r�r�r�rrrr��r�zd['a w�wordzd['a\'r*z"a'b"zd["a'�-zbefore-afterzd['before-afrez'foo'z'foo']ror�r�zd['fzfoo']zfoo"]zd['fooz	d['foo', zd['foo', 'bzd['foo', 'fz	d['foo',]�csr�r�r�r�rrrr��r�zd[""]csr�r�r�r�rrrr��r�z
 241  d["foo","]rcsr�r�r�r�rrrr��r�z	d["foo",])r�r��foobarr�zd['foo', 'bar', 'fo)
 242  rrr�r�r�r�object�anyrUr�rzrrr�test_dict_key_completion_stringOs�
 243  �
 244  z-TestCompleter.test_dict_key_completion_stringcCs�t�}|jj}ddddddd�|jd<|dd�\}}|�d|�|�d|�|�d|�|�d|�|d	d�\}}|�d
 245  |�|dd�\}}|�d|�|�d
 246  |�|dd�\}}|�d|�|�d|�dS)NrYrvzd[1rxr^r_rZz'1999'zd[0xdeadr]zd[2r`razd[0b101rbrc�rrr�r�r�rrzrrr� test_dict_key_completion_numbers�s,�z.TestCompleter.test_dict_key_completion_numbersc	s�t�}|jj�ddi��|jd<G�fdd�d�}||jd<�fdd�|jd<d	�i|jd
 247  <��fdd�}��fd
 248  d�}|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd�td��"t�t��
 249  |dd�Wd�n1s~wYWd�n1s�wY��fdd�}|dd�t��"|dd�|dd�|dd�|dd�|dd�Wd�dS1s�wYdS)z<Test expression contexts in which dict key completion occursrMNrvcseZdZ�ZdS)z:TestCompleter.test_dict_key_completion_contexts.<locals>.CN)rrrsrt�datar�rvrr�Csr�cs�Srrrr�rrr#szATestCompleter.test_dict_key_completion_contexts.<locals>.<lambda>�getr��nestedcsR�di|��\}}��d|���d|���d|���d|���d|�dS)NrMr�rr|r}r)r�rLr�r��r�rlrr�assert_no_completionszMTestCompleter.test_dict_key_completion_contexts.<locals>.assert_no_completioncs.�di|��\}}��d|���d|�dS)Nr|r}r)r�rr�r�rr�assert_completionszJTestCompleter.test_dict_key_completion_contexts.<locals>.assert_completionzd['a'rxzd["a"zd['a' + z	d['a' + 'z+ d[z(d[zC.data[znested['x'][�minimalcs"�di|��\}}��d|�dS)Nzget()['abc']r)r�r�r�rrr�5szget()[zget()['zget()['az	get()['abz
 250  get()['abc)	rrr�r�rG�pytest�raisesr�rD)rlrCr�r�r�r)r�rvrlr�!test_dict_key_completion_contextssB
 251  
 252  
 253  
 254  
 255  
 256  
 257  
 258  
 259  
 260  
 261  ���
 262  
 263  
 264  
 265  
 266  "�z/TestCompleter.test_dict_key_completion_contextscCsHt�}|jj}ddd�|jd<|dd�\}}|�d|�|�d|�dS)z-Test handling of bytes in dict key completionN)rMsabdrvrwrxr|zb'abd'r�rzrrr�test_dict_key_completion_bytesAsz,TestCompleter.test_dict_key_completion_bytescCs�t�}|jj}ddi|jd<tjdkr |dd�\}}|�d|�|dd�\}}|�d|�t��#|dd�\}}|�d	|�|dd�\}}|�d
 267  |�Wd�dS1sVwYdS)z/Test handling of unicode in dict key completionuaאNrvrKz
 268  d['a\u05d0rxZu05d0ud['aאzd['a\u05d0']ud['aא'])rrr�r�r�r�r�rDrzrrr�$test_dict_key_completion_unicode_py3]s
 269  "�z2TestCompleter.test_dict_key_completion_unicode_py3�numpyc	s�ddl�t���jj��jgddgd��jd<�dd�\}}��d	|���d
 270  |���ddd
 271  gfdg���jd�d�}|d�jd<�dd�\}}��d|���d|������fdd�}t	��|�Wd�n1sqwYt
 272  d��|�Wd�n1s�wYt
 273  d��)t�t
 274  ��|�Wd�n1s�wYWd�dSWd�dS1s�wYdS)z7Test dict key completion applies to numpy struct arraysrN)�hello�f)�worldr���dtypervr~rxr�r�Zmy_head)�my_dt�>u4)�my_dfr�)�my_dataz>f4rr�r!r�csV�jd�d��jd<�dd�\}}��tdd�|D�����tdd�|D���dS)	Nr�r�rvzd[1]['my_head']['rxcS�g|]}d|v�qS)r�rr�rrrre�r�z_TestCompleter.test_struct_array_key_completion.<locals>.completes_on_nested.<locals>.<listcomp>cSr�)r�rr�rrrre�r�)�zerosr�r�r�)r�r��r��dtrCr�rlrr�completes_on_nested�szKTestCompleter.test_struct_array_key_completion.<locals>.completes_on_nestedZlimitedr�)r�rrr��arrayr�r�r�r�rDrGr�r�r�)rlr�r�r�r�rr�r� test_struct_array_key_completionws:��
 275  �
 276  ��"�z.TestCompleter.test_struct_array_key_completion�pandascCs�ddl}t�}|jj}|�dgdgd��|jd<|dd�\}}|�d	|�|�d
 277  |�|dd�\}}|�d	|�|�d
 278  |�|dd�\}}|�d	|�|d
 279  d�\}}|�d	|�|dd�\}}|�d	|�|dd�\}}|�d	|�dS)z5Test dict key completion applies to pandas DataFramesrNr!r�)r�r�rvr~rxr�r�z
 280  d.loc[:, 'zd.loc[1:, 'zd.loc[1:1, 'zd.loc[1:1:-1, 'zd.loc[::, ')r�rrr�Z	DataFramer�r�)rlr�rCr�r�r�rrr�test_dataframe_key_completion�s$z+TestCompleter.test_dataframe_key_completioncCs�t�}|jj}d|jd<g|jd<t|jd<i|jd<ddi|jd<|d	d
 281  �\}}|dd
 282  �\}}|dd
 283  �\}}|d
 284  d
 285  �\}}|dd
 286  �\}}|dd
 287  �\}}dS)z1Smoke test cases dict key completion can't handleNZ
 288  no_getitemZno_keysZcant_call_keys�emptyrMrrvzno_getitem['rxz	no_keys['zcant_call_keys['zempty['zname_error['zd['\)rrr�r��dictrzrrr�!test_dict_key_completion_invalids�s
 289  
 290  
 291  
 292  z/TestCompleter.test_dict_key_completion_invalidscCsFt�}tddg�|jd<|jjdd�\}}|�d|�|�d|�dS)N�qwerty�qwickZkey_completablezkey_completable['qwrx)rrvr�rr�r��rlrCr�r�rrr�test_object_key_completion�s
 293  z(TestCompleter.test_object_key_completioncCsNt�}td�td�t|jd<|jjdd�\}}|�d|�|�d|�dS)Nr�r�Znamed_instance_classznamed_instance_class['qwrx)rrjr�rr�r�r�rrr�test_class_key_completion�s
 294  z'TestCompleter.test_class_key_completioncCsddlm}|d�sJ�dS)z]
 295          Test that try-import don't crash on trailing dot, and import modules before
 296          r)�
 297  try_importzIPython.N)ZIPython.core.completerlibr�)rlr�rrr�test_tryimport�szTestCompleter.test_tryimportcC�2t�}|�dd�\}}|�d|�|�d|�dS)Nr(z
 298  %aimport i�ior��rr�r�rr�rrr�test_aimport_module_completer��z+TestCompleter.test_aimport_module_completercCs@t�}|�ddd�\}}|�d|�|�d|�|�d|�dS)Nzimport IPython.co�zIPython.corezimport IPython.corezIPython.displayr�r�rrr�#test_nested_import_module_completer�s
 299  z1TestCompleter.test_nested_import_module_completercCr�)Nr(zimport ir�r�r�r�rrr�test_import_module_completer�r�z*TestCompleter.test_import_module_completercCs4t�}|�ddd�\}}|�d|�|�d|�dS)N�Bzfrom io import B��BytesIO�
 300  BaseExceptionr�r�rrr�test_from_module_completer�sz(TestCompleter.test_from_module_completercCsNt�}d|j_d|jd<d|jd<|�dd�\}}|�d|�|�d|�dS)NFr�Z
 301  some_threerZ	some_fourZs_z	print(s_fr+r�rrr�test_snake_case_completion�s
 302  
 303  z(TestCompleter.test_snake_case_completioncCsTt�}ddlm}d|j_|�|d��|�dd�\}}|�d|�|�d|�dS)Nr)rFaH
 304              class Test:
 305                  def meth(self, meth_arg1):
 306                      print("meth")
 307  
 308                  def meth_1(self, meth1_arg1, meth1_arg2):
 309                      print("meth1")
 310  
 311                  def meth_2(self, meth2_arg1, meth2_arg2):
 312                      print("meth2")
 313              test = Test()
 314              z
 315  test.meth(z
 316  meth_arg1=zmeth2_arg1=)	rrrrrr�r�r�r)rlrCrr�r�rrr�test_mix_termss��zTestCompleter.test_mix_termscCsnt�}|j}d}t��"d|_|�|t|��}|D]}|�|jdd�qWd�dS1s0wYdS)Nz%aTrr/)rrr
 317  rr�r=r�r�)rlrCrr�r�r9rrr�1test_percent_symbol_restrict_to_magic_completionss�"�z?TestCompleter.test_percent_symbol_restrict_to_magic_completionscCsjt�}|j}d}t�� d|_dd�|�|t|��D�}|�|dg�Wd�dS1s.wYdS)Nr�TcS�g|]}|j�qSrr��rcr
 318  rrrre,��z<TestCompleter.test_fwd_unicode_restricts.<locals>.<listcomp>r�)rrr
 319  rr�r=r�)rlrCrr�r�rrr�test_fwd_unicode_restricts%s�"�z(TestCompleter.test_fwd_unicode_restrictscs�t�}|j�ddi}||jd<d���fdd�}|�}|�|dg�t�}ddi|j_��|�|�}|�d|�|�	t
 320  |�d	�dS)
 321  z7Test that dict key suppresses non-dict completion itemsrMNrvr�csJt��d�_dd����t���D�Wd�S1swYdS)NTcSr�rr�r�rrrre=r�zLTestCompleter.test_dict_key_restrict_to_dicts.<locals>._.<locals>.<listcomp>)r
 322  rr�r=r�r9r�rrr�:s�$�z8TestCompleter.test_dict_key_restrict_to_dicts.<locals>._zIPCompleter.dict_key_matcherFr!)rrr�r�rr�suppress_competing_matchersrr�Z
 323  assertGreaterr=)rlrCrvr�r�rrr�r�test_dict_key_restrict_to_dicts1s
 324  �
 325  z-TestCompleter.test_dict_key_restrict_to_dictscsBtdd�dd��}tddd�dtfd	d
 326  ��}tdd�dd
 327  ��}t|||g��qt�}|j���fdd�}|dgd��|ddg�|dddg�|dddg��fdd�}|d�|dgd��|ddi�|dgd��|ddi�|ddg�|ddi�|ddg�|d�|ddg�Wd�dS1s�wYdS)N�	a_matcher��
 328  identifiercS�dgS�N�completion_arr�rrrr�P�z9TestCompleter.test_matcher_suppression.<locals>.a_matcher�	b_matcherr�)r��api_version�contextcSs`|j}dtd�gi}|dkrdh|d<|�d�r.d|d<|dkr%dh|d	<|d
 329  kr.dh|d	<|S)Nr��completion_bz
 330  suppress c�	c_matcher�suppress�suppress allT�suppress all but cZdo_not_suppress�suppress all but ar�)�tokenrr)r�r��resultrrrr�Ts
 331  
 332  
 333  
 334  z9TestCompleter.test_matcher_suppression.<locals>.b_matcherr�cSr�)N�completion_crr�rrrr�er�z9TestCompleter.test_matcher_suppression.<locals>.c_matcherc�$d�_��|�\}}��||�dS�NF�rr�r��r�rSr�r��r9rlrrr�m�z1TestCompleter.test_matcher_suppression.<locals>._zdo not suppress)r�r�r�r�r�r�r�r�r�c�t�}||j_��|�dSr�rrr�r�Zsuppression_configr�r9rr�	configurew�z9TestCompleter.test_matcher_suppression.<locals>.configureFT)rrrHrr)rlr�r�r�rCr�r�rr�r�test_matcher_suppressionOs4
 335  
 336  
 337  "�z&TestCompleter.test_matcher_suppressioncs�tdd�dd��}tdd�dd��}t||g��<t�}|j���fdd	�}�fd
 338  d�}|d�|d
 339  ddg�|d�|d
 340  dg�|d�|dddg�Wd�dS1sWwYdS)N�matcher_returning_iteratorr�cSs
 341  tdg�S)N�completion_iter)�iterr�rrrr��rqzXTestCompleter.test_matcher_suppression_with_iterator.<locals>.matcher_returning_iterator�matcher_returning_listcSr�)N�completion_listrr�rrrr��r�zTTestCompleter.test_matcher_suppression_with_iterator.<locals>.matcher_returning_listcr�r�r�r�r�rrr��r�z?TestCompleter.test_matcher_suppression_with_iterator.<locals>._cr�rr�r�r�rrr��r�zGTestCompleter.test_matcher_suppression_with_iterator.<locals>.configureFz---r�r�Tz--)rrHrr)rlr�r�rCr�r�rr�r�&test_matcher_suppression_with_iterator�s 
 342  
 343  "�z4TestCompleter.test_matcher_suppression_with_iteratorcsZt�}|j�d�_�fdd�}��fdd�}|d�|�|d�|�|d�|�dS)NTcr�rr�r�r�rrr��r�zCTestCompleter.test_matcher_suppression_with_jedi.<locals>.configurecsNt��dd���dd�D�}��d|�Wd�dS1s wYdS)NcSr�rr�r�rrrre�szOTestCompleter.test_matcher_suppression_with_jedi.<locals>._.<locals>.<listcomp>zdict.rrn)r
 344  r�r�)r�r�rrr��s"�z;TestCompleter.test_matcher_suppression_with_jedi.<locals>._Fr)rlrCr�r�rr�r�"test_matcher_suppression_with_jedi�s
 345  z0TestCompleter.test_matcher_suppression_with_jedics�tdd�dd��}tdd�dd��}��fdd	�}t||g��0t�}|j�|d
 346  dg�t�}dg|j_��|�|d
 347  g�g|j_��|�Wd�dS1sRwYdS)Nr�r�cSr�r�rr�rrrr��r�z7TestCompleter.test_matcher_disabling.<locals>.a_matcherr�cSr�)Nr�rr�rrrr��r�z7TestCompleter.test_matcher_disabling.<locals>.b_matcherc���d�\}}��||�dS�NZcompletion_�r�r��rSr�r�r�rrr���z/TestCompleter.test_matcher_disabling.<locals>._r�r�)rrHrrrrZdisable_matchersr)rlr�r�r�rCrrr�r�test_matcher_disabling�s 
 348  
 349  
 350  
 351  
 352  "�z$TestCompleter.test_matcher_disablingcs�tdddd�dd��}tdddd�dd	��}��fd
 353  d�}t||g��t�}|j�|dg�d
 354  |_|dg�Wd�dS1sBwYdS)Nr�rr�)r��priorityr�cS�td�gdd�S)Nr�T�r�r��rr�rrrr���z6TestCompleter.test_matcher_priority.<locals>.a_matcherr�cSr	)Nr�Tr
 355  rr�rrrr��rz6TestCompleter.test_matcher_priority.<locals>.b_matchercrrrrr�rrr��rz.TestCompleter.test_matcher_priority.<locals>._r�r�r�)rrHrrZmatcher_priority)rlr�r�r�rCrr�r�test_matcher_priority�s
 356  
 357  
 358  "�z#TestCompleter.test_matcher_priorityN)Trrrsrtr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��mark�xfailr�r�r�r�r��version_info�releaselevelr�r�rrrrrrrrr#r$r'r,r-r.r1r2r9r<r>rCrDrGrHrdrpr{r�r�r�r�r��decZskip_withoutr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
 359  rrrrrz�s�	
 360  �
 361  
 362  �
 363  
 364  �
 365  #
 366  �
 367  
 368  �
 369  �
 370  
 371  �
 372  G=	//0:
 373  $
 374  
 375  	> 
 376  �
 377  rzz
 378  line,expected)()znp.�	attribute)znp.ranr)znp.random.rand(np.random.ranr)znp.random.rand(n�global)zd['k.e.y.'](ranr)zd[0].kr)za = { 'a': np.ranr)r�r�r[r)z(some_var = "this is a string with a dot.r)z"text = 'another string with a dot.r)zf"greeting {user.nar)zt"welcome {guest.nar)zf"hello {name} worlr)zf"hello {{a.r)z
 379  f"hello {{{a.r)z-var = "string with \"escaped quote and a dot.r)z'escaped = 'single \'quote\' with a dot.r)z'multi = """This is line one
 380  with a dot.r)z0multi_single = '''Another
 381  multi-line
 382  with a dot.r)zx = 5  # This is a commentr)z,y = obj.method()  # Comment after dot.methodr)zd['#'] = np.r)z+complex_expr = (func((obj.method(param.attrr)z$multiple_nesting = {key: [value.attrr)z3.r)z3.14r)z-42.14r)z
 383  x = func(3.14r)zx = func(a3.r)zx = func(a3.12r)z3.1.r)z-3.1.r)z(3).rr)zstr_with_code = "x.attrr)zf"formatted {obj.attrr)zf"formatted {obj.attr}r)z-dict_with_dots = {'key.with.dots': value.attrr)zd[f'{a}']['{a.rcC�4t�}|jj}||�}|j|ksJd|�d���dS)zTest completion context�Failed on input: 'r�N�rrZ_determine_completion_context�value�rXrSrCZget_contextr�rrr�test_completion_context�s8rz$Completion context not yet supportedr�zline, expected))zf'{f'a.r)z3a.r)z$).rcCr)z#Test unsupported completion contextrr�Nrrrrr�#test_unsupported_completion_context9srz setup,code,expected,not_expectedza="str"; b=1z(a, b.z
 384  .bit_countz
 385  .conjugatez.countz(a, b).z.capitalizezx="str"; y=1z
 386  x = {1, y.z
 387  x = [1, y.zx="str"; y=1; fun=lambda x:xz
 388  x = fun(1, y.c	Cs�t�}|j}|�|�t��Itd��,|�|�}t|�t|�t�ks*Jt|���t|��t|��t�ks8J�Wd�n1sBwYWd�dSWd�dS1sZwYdSr�)rrr�r
 389  rr�r��intersection)�setup�coderSZnot_expectedrCr9r�rrr�test_misc_no_jedi_completionsJs
 390  
 391  "P�r z
 392  code,expected)	)z (a, br*)z(a, br*)�(a, b)r[)z (a, b)r!)z [a, b]z[a, b])z a, br*)z	x = {1, yr`)z	x = [1, yr`)zx = fun(1, yr`cCst�j}|�|�|ks
 393  J�dSr)rrZ
 394  _trim_expr)rrSr9rrr�test_trim_expr^sr"zinput, expectedz1.234z+1z-1z-1.0z-1.z+1.z.1z1..z..z.1.z,1r�z, 1z, .1z, +.1z+.1z.1 Z0b_0011_1111_0100_1110r]Z0b_1110_0101z1 + 1z, 1 + 1cCst|�|ksJ�dSr)r)r�rSrrr�'test_match_numeric_literal_for_dict_keyqs r#)A�__doc__r�r�r�rZunittestr��importlib.metadatar�
 395  contextlibrZtraitlets.config.loaderrZIPythonrZIPython.corerZIPython.utils.tempdirrrZIPython.utils.genericsr	ZIPython.testingr
 396  rZIPython.core.latex_symbolsrZIPython.core.completerrr
 397  rrrrrrrrZpackaging.versionr�boolrr<rBrDrbrGrHr��pairsrZparametrizerTrZrirjrvZTestCaserzrrrr r"r#rrrr�<module>s�0
 398  )!
 399  
 400  
 401  
 402  
 403  	
 404  
 405  �
 406  6���
 407  
 408  
 409  �
 410  ��