##// END OF EJS Templates
Backport PR #10030: Fix running %run -d twice...
Matthias Bussonnier -
Show More
@@ -806,6 +806,11 b' python-profiler package from non-free.""")'
806 self.shell.InteractiveTB.pdb = self.shell.InteractiveTB.debugger_cls()
806 self.shell.InteractiveTB.pdb = self.shell.InteractiveTB.debugger_cls()
807 deb = self.shell.InteractiveTB.pdb
807 deb = self.shell.InteractiveTB.pdb
808
808
809 # deb.checkline() fails if deb.curframe exists but is None; it can
810 # handle it not existing. https://github.com/ipython/ipython/issues/10028
811 if hasattr(deb, 'curframe'):
812 del deb.curframe
813
809 # reset Breakpoint state, which is moronically kept
814 # reset Breakpoint state, which is moronically kept
810 # in a class
815 # in a class
811 bdb.Breakpoint.next = 1
816 bdb.Breakpoint.next = 1
@@ -209,9 +209,16 b' class TestMagicRunPass(tt.TempFileMixin):'
209 def test_run_profile( self ):
209 def test_run_profile( self ):
210 """Test that the option -p, which invokes the profiler, do not
210 """Test that the option -p, which invokes the profiler, do not
211 crash by invoking execfile"""
211 crash by invoking execfile"""
212 _ip = get_ipython()
213 self.run_tmpfile_p()
212 self.run_tmpfile_p()
214
213
214 def test_run_debug_twice(self):
215 # https://github.com/ipython/ipython/issues/10028
216 _ip = get_ipython()
217 with tt.fake_input(['c']):
218 _ip.magic('run -d %s' % self.fname)
219 with tt.fake_input(['c']):
220 _ip.magic('run -d %s' % self.fname)
221
215
222
216 class TestMagicRunSimple(tt.TempFileMixin):
223 class TestMagicRunSimple(tt.TempFileMixin):
217
224
@@ -7,16 +7,8 b' Authors'
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 #-----------------------------------------------------------------------------
10 # Copyright (c) IPython Development Team.
11 # Copyright (C) 2009 The IPython Development Team
11 # Distributed under the terms of the Modified BSD License.
12 #
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
15 #-----------------------------------------------------------------------------
16
17 #-----------------------------------------------------------------------------
18 # Imports
19 #-----------------------------------------------------------------------------
20
12
21 import os
13 import os
22 import re
14 import re
@@ -26,6 +18,7 b' import tempfile'
26 from contextlib import contextmanager
18 from contextlib import contextmanager
27 from io import StringIO
19 from io import StringIO
28 from subprocess import Popen, PIPE
20 from subprocess import Popen, PIPE
21 from unittest.mock import patch
29
22
30 try:
23 try:
31 # These tools are used by parts of the runtime, so we make the nose
24 # These tools are used by parts of the runtime, so we make the nose
@@ -46,9 +39,6 b' from IPython.utils.encoding import DEFAULT_ENCODING'
46 from . import decorators as dec
39 from . import decorators as dec
47 from . import skipdoctest
40 from . import skipdoctest
48
41
49 #-----------------------------------------------------------------------------
50 # Functions and classes
51 #-----------------------------------------------------------------------------
52
42
53 # The docstring for full_path doctests differently on win32 (different path
43 # The docstring for full_path doctests differently on win32 (different path
54 # separator) so just skip the doctest there. The example remains informative.
44 # separator) so just skip the doctest there. The example remains informative.
@@ -444,6 +434,25 b' def make_tempfile(name):'
444 finally:
434 finally:
445 os.unlink(name)
435 os.unlink(name)
446
436
437 def fake_input(inputs):
438 """Temporarily replace the input() function to return the given values
439
440 Use as a context manager:
441
442 with fake_input(['result1', 'result2']):
443 ...
444
445 Values are returned in order. If input() is called again after the last value
446 was used, EOFError is raised.
447 """
448 it = iter(inputs)
449 def mock_input(prompt=''):
450 try:
451 return next(it)
452 except StopIteration:
453 raise EOFError('No more inputs given')
454
455 return patch('builtins.input', mock_input)
447
456
448 def help_output_test(subcommand=''):
457 def help_output_test(subcommand=''):
449 """test that `ipython [subcommand] -h` works"""
458 """test that `ipython [subcommand] -h` works"""
General Comments 0
You need to be logged in to leave comments. Login now