
    }e                         d Z ddlZddlZ eej                  j                  d      dd D  cg c]
  }  e|        c}       Zd Zd Z	d Z
d Zd	 Zed
k  rd Zd Zd Zyc c} w )zTTests for the key interactiveshell module, where the main ipython class is defined.
    N.   c                  |   t         j                          t        t         j                        } t        t         j                        }dt         j                  d<   dt         j                  d<   t         j                          t        t         j                        | k(  sJ t        t         j                        |k(  sJ y)z!reset must clear most namespaces.   xyN)ipresetlenuser_nsuser_ns_hidden)nvars_user_nsnvars_hiddens     ?/usr/lib/python3/dist-packages/IPython/core/tests/test_iplib.py
test_resetr   
   s     HHJ 

OMr(()L BJJsOBJJsOHHJ rzz?m+++r  !\111    c                       y)a  
    In [18]: xmode plain
    Exception reporting mode: Plain

    In [19]: run simpleerr.py
    Traceback (most recent call last):
      File ...:...
        bar(mode)
      File ...:... in bar
        div0()
      File ...:... in div0
        x/y
    ZeroDivisionError: ...
    N r   r   r   doctest_tb_plainr   #       r   c                       y)a  
    In [3]: xmode context
    Exception reporting mode: Context

    In [4]: run simpleerr.py
    ---------------------------------------------------------------------------
    ZeroDivisionError                         Traceback (most recent call last)
    <BLANKLINE>
    ...
         30     except IndexError:
         31         mode = 'div'
    ---> 33     bar(mode)
    <BLANKLINE>
    ... in bar(mode)
         15     "bar"
         16     if mode=='div':
    ---> 17         div0()
         18     elif mode=='exit':
         19         try:
    <BLANKLINE>
    ... in div0()
          6     x = 1
          7     y = 0
    ----> 8     x/y
    <BLANKLINE>
    ZeroDivisionError: ...Nr   r   r   r   doctest_tb_contextr   4   r   r   c                       y)a  
    In [5]: xmode verbose
    Exception reporting mode: Verbose

    In [6]: run simpleerr.py
    ---------------------------------------------------------------------------
    ZeroDivisionError                         Traceback (most recent call last)
    <BLANKLINE>
    ...
         30     except IndexError:
         31         mode = 'div'
    ---> 33     bar(mode)
            mode = 'div'
    <BLANKLINE>
    ... in bar(mode='div')
         15     "bar"
         16     if mode=='div':
    ---> 17         div0()
         18     elif mode=='exit':
         19         try:
    <BLANKLINE>
    ... in div0()
          6     x = 1
          7     y = 0
    ----> 8     x/y
            x = 1
            y = 0
    <BLANKLINE>
    ZeroDivisionError: ...
    Nr   r   r   r   doctest_tb_verboser   Q   r   r   c                       y)au  
    In [17]: %xmode plain
    Exception reporting mode: Plain

    In [18]: %run simpleerr.py exit
    An exception has occurred, use %tb to see the full traceback.
    SystemExit: (1, 'Mode = exit')

    In [19]: %run simpleerr.py exit 2
    An exception has occurred, use %tb to see the full traceback.
    SystemExit: (2, 'Mode = exit')

    In [20]: %tb
    Traceback (most recent call last):
      File ...:... in execfile
        exec(compiler(f.read(), fname, "exec"), glob, loc)
      File ...:...
        bar(mode)
      File ...:... in bar
        sysexit(stat, mode)
      File ...:... in sysexit
        raise SystemExit(stat, f"Mode = {mode}")
    SystemExit: (2, 'Mode = exit')

    In [21]: %xmode context
    Exception reporting mode: Context

    In [22]: %tb
    ---------------------------------------------------------------------------
    SystemExit                                Traceback (most recent call last)
    File ..., in execfile(fname, glob, loc, compiler)
         ... with open(fname, "rb") as f:
         ...     compiler = compiler or compile
    ---> ...     exec(compiler(f.read(), fname, "exec"), glob, loc)
    ...
         30     except IndexError:
         31         mode = 'div'
    ---> 33     bar(mode)
    <BLANKLINE>
    ...bar(mode)
         21         except:
         22             stat = 1
    ---> 23         sysexit(stat, mode)
         24     else:
         25         raise ValueError('Unknown mode')
    <BLANKLINE>
    ...sysexit(stat, mode)
         10 def sysexit(stat, mode):
    ---> 11     raise SystemExit(stat, f"Mode = {mode}")
    <BLANKLINE>
    SystemExit: (2, 'Mode = exit')
    Nr   r   r   r   doctest_tb_sysexitr   r   r   r   )r      c                       y)a  
        In [18]: %run simpleerr.py exit
        An exception has occurred, use %tb to see the full traceback.
        SystemExit: (1, 'Mode = exit')

        In [19]: %run simpleerr.py exit 2
        An exception has occurred, use %tb to see the full traceback.
        SystemExit: (2, 'Mode = exit')

        In [23]: %xmode verbose
        Exception reporting mode: Verbose

        In [24]: %tb
        ---------------------------------------------------------------------------
        SystemExit                                Traceback (most recent call last)
        <BLANKLINE>
        ...
            30     except IndexError:
            31         mode = 'div'
        ---> 33     bar(mode)
                mode = 'exit'
        <BLANKLINE>
        ... in bar(mode='exit')
            ...     except:
            ...         stat = 1
        ---> ...     sysexit(stat, mode)
                mode = 'exit'
                stat = 2
            ...     else:
            ...         raise ValueError('Unknown mode')
        <BLANKLINE>
        ... in sysexit(stat=2, mode='exit')
            10 def sysexit(stat, mode):
        ---> 11     raise SystemExit(stat, f"Mode = {mode}")
                stat = 2
        <BLANKLINE>
        SystemExit: (2, 'Mode = exit')
        Nr   r   r   r   (doctest_tb_sysexit_verbose_stack_data_05r      r   r   c                      dd l } t        j                  d       t        j                  d       t        j                  d   dk(  sJ | j	                  d      }t        j                  |       y )Nr   za = 10
a+=1zassert a == 11
assert 1a   z
    if 1:
        print "hello"
        if 1:
            print "world"
        
    if 2:
        print "foo"

    if 3:
        print "bar"

    if 4:
        print "bar"
    
    )textwrapr	   run_cellr   dedent)r#   complexs     r   test_run_cellr'      sU    KKKK*+::c?b   oo	G& KKr   c                      dt         j                  d<   t         j                  d   dk(  sJ t         j                  d= dt         j                  vsJ y)z9Test the internal database used for variable persistence.   __unittest_N)r	   dbr   r   r   test_dbr,      sE    BEE-552%%%
m%%%r   )__doc__
stack_datasystuple__version__splitint
SV_VERSIONr   r   r   r   r   r   r'   r,   )r   s   0r   <module>r5      s     
J$:$:$@$@$Ea$JKqCFKL
22":B4n &R:&U Ls   A!