diff --git a/IPython/core/tests/simpleerr.py b/IPython/core/tests/simpleerr.py index 34e6970..5ba5084 100644 --- a/IPython/core/tests/simpleerr.py +++ b/IPython/core/tests/simpleerr.py @@ -8,7 +8,7 @@ def div0(): x/y def sysexit(stat, mode): - raise SystemExit(stat, 'Mode = %s' % mode) + raise SystemExit(stat, f'Mode = {mode}') def bar(mode): "bar" diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index 6804c2b..0ee1b8d 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -118,91 +118,83 @@ def doctest_tb_verbose(): """ -# TODO : Marc 2021 – this seem to fail due -# to upstream changes in CI for whatever reason. -# Commenting for now, to revive someday (maybe?) -# nose won't work in 3.10 anyway and we'll have to disable iptest. -# thus this likely need to bemigrated to pytest. - - -# def doctest_tb_sysexit(): -# """ -# 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 -# bar(mode) -# File ... line 22, in bar -# sysexit(stat, mode) -# File ... line 11, in sysexit -# raise SystemExit(stat, 'Mode = %s' % mode) -# SystemExit: (2, 'Mode = exit') -# -# In [21]: %xmode context -# Exception reporting mode: Context -# -# In [22]: %tb -# --------------------------------------------------------------------------- -# SystemExit Traceback (most recent call last) -# -# ... -# 29 except IndexError: -# 30 mode = 'div' -# ---> 32 bar(mode) -# -# ...bar(mode) -# 20 except: -# 21 stat = 1 -# ---> 22 sysexit(stat, mode) -# 23 else: -# 24 raise ValueError('Unknown mode') -# -# ...sysexit(stat, mode) -# 10 def sysexit(stat, mode): -# ---> 11 raise SystemExit(stat, 'Mode = %s' % mode) -# -# SystemExit: (2, 'Mode = exit') -# -# In [23]: %xmode verbose -# Exception reporting mode: Verbose -# -# In [24]: %tb -# --------------------------------------------------------------------------- -# SystemExit Traceback (most recent call last) -# -# ... in -# 29 except IndexError: -# 30 mode = 'div' -# ---> 32 bar(mode) -# mode = 'exit' -# -# ... in bar(mode='exit') -# 20 except: -# 21 stat = 1 -# ---> 22 sysexit(stat, mode) -# mode = 'exit' -# stat = 2 -# 23 else: -# 24 raise ValueError('Unknown mode') -# -# ... in sysexit(stat=2, mode='exit') -# 10 def sysexit(stat, mode): -# ---> 11 raise SystemExit(stat, 'Mode = %s' % mode) -# stat = 2 -# mode = 'exit' -# -# SystemExit: (2, 'Mode = exit') -# """ +def doctest_tb_sysexit(): + """ + 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 + bar(mode) + File ... line 22, in bar + sysexit(stat, mode) + File ... line 11, 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) + + ... + 29 except IndexError: + 30 mode = 'div' + ---> 32 bar(mode) + + ...bar(mode) + 20 except: + 21 stat = 1 + ---> 22 sysexit(stat, mode) + 23 else: + 24 raise ValueError('Unknown mode') + + ...sysexit(stat, mode) + 10 def sysexit(stat, mode): + ---> 11 raise SystemExit(stat, f'Mode = {mode}') + + SystemExit: (2, 'Mode = exit') + + In [23]: %xmode verbose + Exception reporting mode: Verbose + + In [24]: %tb + --------------------------------------------------------------------------- + SystemExit Traceback (most recent call last) + + ... in + 29 except IndexError: + 30 mode = 'div' + ---> 32 bar(mode) + mode = 'exit' + + ... in bar(mode='exit') + 20 except: + 21 stat = 1 + ---> 22 sysexit(stat, mode) + mode = 'exit' + stat = 2 + 23 else: + 24 raise ValueError('Unknown mode') + + ... in sysexit(stat=2, mode='exit') + 10 def sysexit(stat, mode): + ---> 11 raise SystemExit(stat, f'Mode = {mode}') + stat = 2 + + SystemExit: (2, 'Mode = exit') + """ def test_run_cell():