diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index ef9ae1b..0d036e1 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -849,6 +849,7 @@ python-profiler package from non-free.""") bdb.Breakpoint.next = 1 bdb.Breakpoint.bplist = {} bdb.Breakpoint.bpbynumber = [None] + deb.clear_all_breaks() if bp_line is not None: # Set an initial breakpoint to stop execution maxtries = 10 diff --git a/IPython/core/tests/test_run.py b/IPython/core/tests/test_run.py index e089413..1b904f0 100644 --- a/IPython/core/tests/test_run.py +++ b/IPython/core/tests/test_run.py @@ -165,8 +165,8 @@ def doctest_reset_del(): class TestMagicRunPass(tt.TempFileMixin): def setup(self): - """Make a valid python temp file.""" - self.mktmp('pass\n') + content = "a = [1,2,3]\nb = 1" + self.mktmp(content) def run_tmpfile(self): _ip = get_ipython() @@ -213,6 +213,16 @@ class TestMagicRunPass(tt.TempFileMixin): with tt.fake_input(['c']): _ip.magic('run -d %s' % self.fname) + def test_run_debug_twice_with_breakpoint(self): + """Make a valid python temp file.""" + _ip = get_ipython() + with tt.fake_input(['b 2', 'c', 'c']): + _ip.magic('run -d %s' % self.fname) + + with tt.fake_input(['c']): + with tt.AssertNotPrints('KeyError'): + _ip.magic('run -d %s' % self.fname) + class TestMagicRunSimple(tt.TempFileMixin):