Format: application/x-python-code
⬇ Download File (6.7 KB)
   1  o
   2  
   3  ��h�@s�dZddlZddlZedd�ej�d�dd�D��Zdd�Zd	d
   4  �Zdd�Z	d
   5  d�Z
   6  dd�Zedkr7dd�Zdd�Z
   7  dd�ZdS)zTTests for the key interactiveshell module, where the main ipython class is defined.
   8  �NcCsg|]}t|��qS�)�int)�.0�xrr�Sc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_iplib.py�
   9  <listcomp>sr�.�cCs`t��ttj�}ttj�}dtjd<dtjd<t��ttj�|ks%J�ttj�|ks.J�dS)z!reset must clear most namespaces.�r�yN)�ip�reset�len�user_nsZuser_ns_hidden)Z
  10  nvars_user_nsZnvars_hiddenrrr�
  11  test_reset
  12  s
  13  
  14  
  15  
  16  rcC�dS)a
  17      In [18]: xmode plain
  18      Exception reporting mode: Plain
  19  
  20      In [19]: run simpleerr.py
  21      Traceback (most recent call last):
  22        File ...:...
  23          bar(mode)
  24        File ...:... in bar
  25          div0()
  26        File ...:... in div0
  27          x/y
  28      ZeroDivisionError: ...
  29      Nrrrrr�doctest_tb_plain#�rcCr)a�
  30      In [3]: xmode context
  31      Exception reporting mode: Context
  32  
  33      In [4]: run simpleerr.py
  34      ---------------------------------------------------------------------------
  35      ZeroDivisionError                         Traceback (most recent call last)
  36      <BLANKLINE>
  37      ...
  38           30     except IndexError:
  39           31         mode = 'div'
  40      ---> 33     bar(mode)
  41      <BLANKLINE>
  42      ... in bar(mode)
  43           15     "bar"
  44           16     if mode=='div':
  45      ---> 17         div0()
  46           18     elif mode=='exit':
  47           19         try:
  48      <BLANKLINE>
  49      ... in div0()
  50            6     x = 1
  51            7     y = 0
  52      ----> 8     x/y
  53      <BLANKLINE>
  54      ZeroDivisionError: ...Nrrrrr�doctest_tb_context4rrcCr)a�
  55      In [5]: xmode verbose
  56      Exception reporting mode: Verbose
  57  
  58      In [6]: run simpleerr.py
  59      ---------------------------------------------------------------------------
  60      ZeroDivisionError                         Traceback (most recent call last)
  61      <BLANKLINE>
  62      ...
  63           30     except IndexError:
  64           31         mode = 'div'
  65      ---> 33     bar(mode)
  66              mode = 'div'
  67      <BLANKLINE>
  68      ... in bar(mode='div')
  69           15     "bar"
  70           16     if mode=='div':
  71      ---> 17         div0()
  72           18     elif mode=='exit':
  73           19         try:
  74      <BLANKLINE>
  75      ... in div0()
  76            6     x = 1
  77            7     y = 0
  78      ----> 8     x/y
  79              x = 1
  80              y = 0
  81      <BLANKLINE>
  82      ZeroDivisionError: ...
  83      Nrrrrr�doctest_tb_verboseQrrcCr)au
  84      In [17]: %xmode plain
  85      Exception reporting mode: Plain
  86  
  87      In [18]: %run simpleerr.py exit
  88      An exception has occurred, use %tb to see the full traceback.
  89      SystemExit: (1, 'Mode = exit')
  90  
  91      In [19]: %run simpleerr.py exit 2
  92      An exception has occurred, use %tb to see the full traceback.
  93      SystemExit: (2, 'Mode = exit')
  94  
  95      In [20]: %tb
  96      Traceback (most recent call last):
  97        File ...:... in execfile
  98          exec(compiler(f.read(), fname, "exec"), glob, loc)
  99        File ...:...
 100          bar(mode)
 101        File ...:... in bar
 102          sysexit(stat, mode)
 103        File ...:... in sysexit
 104          raise SystemExit(stat, f"Mode = {mode}")
 105      SystemExit: (2, 'Mode = exit')
 106  
 107      In [21]: %xmode context
 108      Exception reporting mode: Context
 109  
 110      In [22]: %tb
 111      ---------------------------------------------------------------------------
 112      SystemExit                                Traceback (most recent call last)
 113      File ..., in execfile(fname, glob, loc, compiler)
 114           ... with open(fname, "rb") as f:
 115           ...     compiler = compiler or compile
 116      ---> ...     exec(compiler(f.read(), fname, "exec"), glob, loc)
 117      ...
 118           30     except IndexError:
 119           31         mode = 'div'
 120      ---> 33     bar(mode)
 121      <BLANKLINE>
 122      ...bar(mode)
 123           21         except:
 124           22             stat = 1
 125      ---> 23         sysexit(stat, mode)
 126           24     else:
 127           25         raise ValueError('Unknown mode')
 128      <BLANKLINE>
 129      ...sysexit(stat, mode)
 130           10 def sysexit(stat, mode):
 131      ---> 11     raise SystemExit(stat, f"Mode = {mode}")
 132      <BLANKLINE>
 133      SystemExit: (2, 'Mode = exit')
 134      Nrrrrr�doctest_tb_sysexitrrr)r�cCr)a
 135          In [18]: %run simpleerr.py exit
 136          An exception has occurred, use %tb to see the full traceback.
 137          SystemExit: (1, 'Mode = exit')
 138  
 139          In [19]: %run simpleerr.py exit 2
 140          An exception has occurred, use %tb to see the full traceback.
 141          SystemExit: (2, 'Mode = exit')
 142  
 143          In [23]: %xmode verbose
 144          Exception reporting mode: Verbose
 145  
 146          In [24]: %tb
 147          ---------------------------------------------------------------------------
 148          SystemExit                                Traceback (most recent call last)
 149          <BLANKLINE>
 150          ...
 151              30     except IndexError:
 152              31         mode = 'div'
 153          ---> 33     bar(mode)
 154                  mode = 'exit'
 155          <BLANKLINE>
 156          ... in bar(mode='exit')
 157              ...     except:
 158              ...         stat = 1
 159          ---> ...     sysexit(stat, mode)
 160                  mode = 'exit'
 161                  stat = 2
 162              ...     else:
 163              ...         raise ValueError('Unknown mode')
 164          <BLANKLINE>
 165          ... in sysexit(stat=2, mode='exit')
 166              10 def sysexit(stat, mode):
 167          ---> 11     raise SystemExit(stat, f"Mode = {mode}")
 168                  stat = 2
 169          <BLANKLINE>
 170          SystemExit: (2, 'Mode = exit')
 171          Nrrrrr�(doctest_tb_sysexit_verbose_stack_data_05�rrcCsFddl}t�d�t�d�tjddksJ�|�d�}t�|�dS)Nrza = 10
 172  a+=1zassert a == 11
 173  assert 1�a�z�
 174      if 1:
 175          print "hello"
 176          if 1:
 177              print "world"
 178          
 179      if 2:
 180          print "foo"
 181  
 182      if 3:
 183          print "bar"
 184  
 185      if 4:
 186          print "bar"
 187      
 188      )�textwraprZrun_cellr�dedent)r�complexrrr�
 189  test_run_cell�s
 190  
 191  �rcCs6dtjd<tjddksJ�tjd=dtjvsJ�dS)z9Test the internal database used for variable persistence.�Z__unittest_N)r�dbrrrr�test_db�s
 192  r!)�__doc__Z
 193  stack_data�sys�tuple�__version__�splitZ
 194  SV_VERSIONrrrrrrrr!rrrr�<module>s"!7)