From 8ca7b420a29ad781cc6c701dd4a6af0dd21b35c4 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Sun, 30 Oct 2022 09:10:13 +0100 Subject: [PATCH 1/3] fix stack-data 0.6 failing tests --- IPython/core/tests/test_iplib.py | 129 ++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 44 deletions(-) diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index f12601823d1..dec429fbe35 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -1,15 +1,10 @@ """Tests for the key interactiveshell module, where the main ipython class is defined. """ -#----------------------------------------------------------------------------- -# Module imports -#----------------------------------------------------------------------------- +import stack_data -# 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.""" @@ -170,46 +165,92 @@ 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') +if SV_VERSION < (0, 6): - In [19]: %run simpleerr.py exit 2 - An exception has occurred, use %tb to see the full traceback. - SystemExit: (2, 'Mode = exit') + 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) + + ... + 30 except IndexError: + 31 mode = 'div' + ---> 33 bar(mode) + mode = 'exit' + + ... in bar(mode='exit') + ... except: + ... stat = 1 + ---> ... sysexit(stat, mode) + mode = 'exit' + stat = 2 + ... else: + ... 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') + """ - In [23]: %xmode verbose - Exception reporting mode: Verbose - - In [24]: %tb - --------------------------------------------------------------------------- - SystemExit Traceback (most recent call last) - - ... - 30 except IndexError: - 31 mode = 'div' - ---> 33 bar(mode) - mode = 'exit' - - ... in bar(mode='exit') - ... except: - ... stat = 1 - ---> ... sysexit(stat, mode) - mode = 'exit' - stat = 2 - ... else: - ... 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') - """ +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) + + ... + 30 except IndexError: + 31 mode = 'div' + ---> 33 bar(mode) + mode = 'exit' + + ... in bar(mode='exit') + ... except: + ... stat = 1 + ---> ... sysexit(stat, mode) + mode = 'exit' + stat = 2 + ... else: + ... raise ValueError('Unknown mode') + + ... in sysexit(stat=2, mode='exit') + 10 def sysexit(stat, mode): + ---> 11 raise SystemExit(stat, f"Mode = {mode}") + stat = 2 + mode = 'exit' + + SystemExit: (2, 'Mode = exit') + """ def test_run_cell(): import textwrap From fcdcddd5e528844672688e07bfa5188e48e37521 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Sun, 30 Oct 2022 09:20:57 +0100 Subject: [PATCH 2/3] iterate --- IPython/core/tests/test_iplib.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index dec429fbe35..8fdf2675ba1 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -229,22 +229,22 @@ def doctest_tb_sysexit_verbose_stack_data_06(): SystemExit Traceback (most recent call last) ... - 30 except IndexError: - 31 mode = 'div' + 30 except IndexError: + 31 mode = 'div' ---> 33 bar(mode) mode = 'exit' ... in bar(mode='exit') - ... except: - ... stat = 1 + ... except: + ... stat = 1 ---> ... sysexit(stat, mode) mode = 'exit' stat = 2 - ... else: - ... raise ValueError('Unknown mode') + ... else: + ... raise ValueError('Unknown mode') ... in sysexit(stat=2, mode='exit') - 10 def sysexit(stat, mode): + 10 def sysexit(stat, mode): ---> 11 raise SystemExit(stat, f"Mode = {mode}") stat = 2 mode = 'exit' From 98e3599e130e253f292679f74982a3a2cd3a7a7a Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Sun, 30 Oct 2022 09:27:22 +0100 Subject: [PATCH 3/3] exclude 3.8 import sys --- IPython/core/tests/test_iplib.py | 174 ++++++++++++++++--------------- 1 file changed, 88 insertions(+), 86 deletions(-) diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index 8fdf2675ba1..c5e065005f0 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -2,6 +2,7 @@ """ import stack_data +import sys SV_VERSION = tuple([int(x) for x in stack_data.__version__.split(".")[0:2]]) @@ -165,92 +166,93 @@ def doctest_tb_sysexit(): """ -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) - - ... - 30 except IndexError: - 31 mode = 'div' - ---> 33 bar(mode) - mode = 'exit' - - ... in bar(mode='exit') - ... except: - ... stat = 1 - ---> ... sysexit(stat, mode) - mode = 'exit' - stat = 2 - ... else: - ... 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') - """ - -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) - - ... - 30 except IndexError: - 31 mode = 'div' - ---> 33 bar(mode) - mode = 'exit' - - ... in bar(mode='exit') - ... except: - ... stat = 1 - ---> ... sysexit(stat, mode) - mode = 'exit' - stat = 2 - ... else: - ... raise ValueError('Unknown mode') - - ... in sysexit(stat=2, mode='exit') - 10 def sysexit(stat, mode): - ---> 11 raise SystemExit(stat, f"Mode = {mode}") - stat = 2 - mode = 'exit' - - 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) + + ... + 30 except IndexError: + 31 mode = 'div' + ---> 33 bar(mode) + mode = 'exit' + + ... in bar(mode='exit') + ... except: + ... stat = 1 + ---> ... sysexit(stat, mode) + mode = 'exit' + stat = 2 + ... else: + ... 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') + """ + + 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) + + ... + 30 except IndexError: + 31 mode = 'div' + ---> 33 bar(mode) + mode = 'exit' + + ... in bar(mode='exit') + ... except: + ... stat = 1 + ---> ... sysexit(stat, mode) + mode = 'exit' + stat = 2 + ... else: + ... raise ValueError('Unknown mode') + + ... in sysexit(stat=2, mode='exit') + 10 def sysexit(stat, mode): + ---> 11 raise SystemExit(stat, f"Mode = {mode}") + stat = 2 + mode = 'exit' + + SystemExit: (2, 'Mode = exit') + """ def test_run_cell(): import textwrap