From 746a8d8e423db6060605e77788c972ee9a9f67ee 2019-07-23 21:44:54 From: Matthias Bussonnier Date: 2019-07-23 21:44:54 Subject: [PATCH] Add a test for reset behavior --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 716e7cc..47db895 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -371,6 +371,31 @@ def test_reset_in_length(): _ip.run_cell("reset -f in") nt.assert_equal(len(_ip.user_ns['In']), _ip.displayhook.prompt_count+1) +class TestResetErrors(TestCase): + + def test_reset_redefine(self): + + @magics_class + class KernelMagics(Magics): + @line_magic + def less(self, shell): pass + + _ip.register_magics(KernelMagics) + + with self.assertLogs() as cm: + # hack, we want to just capture logs, but assertLogs fails if not + # logs get produce. + # so log one things we ignore. + import logging as log_mod + log = log_mod.getLogger() + log.info('Nothing') + # end hack. + _ip.run_cell("reset -f") + + assert len(cm.output) == 1 + for out in cm.output: + assert "Invalid alias" not in out + def test_tb_syntaxerror(): """test %tb after a SyntaxError""" ip = get_ipython()