diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index b9b5ced..877e7cb 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -816,6 +816,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 afe01a7..c1e7734 100644 --- a/IPython/core/tests/test_run.py +++ b/IPython/core/tests/test_run.py @@ -171,8 +171,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() @@ -219,6 +219,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):