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