Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stack-data 0.6 failing tests #13804

Merged
merged 3 commits into from Oct 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
137 changes: 90 additions & 47 deletions IPython/core/tests/test_iplib.py
@@ -1,15 +1,11 @@
"""Tests for the key interactiveshell module, where the main ipython class is defined.
"""
#-----------------------------------------------------------------------------
# Module imports
#-----------------------------------------------------------------------------

import stack_data
import sys

# our own packages
SV_VERSION = tuple([int(x) for x in stack_data.__version__.split(".")[0:2]])

#-----------------------------------------------------------------------------
# Test functions
#-----------------------------------------------------------------------------

def test_reset():
"""reset must clear most namespaces."""
Expand Down Expand Up @@ -170,46 +166,93 @@ def doctest_tb_sysexit():
"""


def doctest_tb_sysexit_verbose():
"""
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')
"""

if sys.version_info >= (3, 9):
if SV_VERSION < (0, 6):

def doctest_tb_sysexit_verbose_stack_data_05():
"""
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')
"""

else:
# currently the only difference is
# + mode = 'exit'

def doctest_tb_sysexit_verbose_stack_data_06():
"""
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
mode = 'exit'
<BLANKLINE>
SystemExit: (2, 'Mode = exit')
"""

def test_run_cell():
import textwrap
Expand Down