o
    û›h  ã                   @   s‚   d Z ddlZddlZedd„ ej d¡dd… D ƒƒZdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zedk r7dd„ Zdd„ Zdd„ ZdS )zTTests for the key interactiveshell module, where the main ipython class is defined.
é    Nc                 C   s   g | ]}t |ƒ‘qS © )Úint)Ú.0Úxr   r   úSc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/tests/test_iplib.pyÚ
<listcomp>   s    r   Ú.é   c                  C   s`   t  ¡  tt jƒ} tt jƒ}dt jd< dt jd< t  ¡  tt jƒ| ks%J ‚tt jƒ|ks.J ‚dS )z!reset must clear most namespaces.é   r   ÚyN)ÚipÚresetÚlenÚuser_nsZuser_ns_hidden)Znvars_user_nsZnvars_hiddenr   r   r   Ú
test_reset
   s   



r   c                   C   ó   dS )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: ...
    Nr   r   r   r   r   Údoctest_tb_plain#   ó    r   c                   C   r   )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   r   Údoctest_tb_context4   r   r   c                   C   r   )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   r   Údoctest_tb_verboseQ   r   r   c                   C   r   )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   r   Údoctest_tb_sysexitr   r   r   )r   é   c                   C   r   )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   r   Ú(doctest_tb_sysexit_verbose_stack_data_05«   r   r   c                  C   sF   dd l } t d¡ t d¡ tjd dksJ ‚|  d¡}t |¡ d S )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   Zrun_cellr   Údedent)r   Úcomplexr   r   r   Útest_run_cellÔ   s   

ÿr   c                   C   s6   dt jd< t jd dksJ ‚t jd= dt jvsJ ‚dS )z9Test the internal database used for variable persistence.é   Z__unittest_N)r   Údbr   r   r   r   Útest_dbñ   s   
r!   )Ú__doc__Z
stack_dataÚsysÚtupleÚ__version__ÚsplitZ
SV_VERSIONr   r   r   r   r   r   r   r!   r   r   r   r   Ú<module>   s    "!7)