Show More
@@ -2252,7 +2252,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2252 | self.showtraceback() |
|
2252 | self.showtraceback() | |
2253 | warn('Unknown failure executing file: <%s>' % fname) |
|
2253 | warn('Unknown failure executing file: <%s>' % fname) | |
2254 |
|
2254 | |||
2255 |
def run_cell(self, raw_cell, store_history= |
|
2255 | def run_cell(self, raw_cell, store_history=False): | |
2256 | """Run a complete IPython cell. |
|
2256 | """Run a complete IPython cell. | |
2257 |
|
2257 | |||
2258 | Parameters |
|
2258 | Parameters |
@@ -3246,7 +3246,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3246 | if not par: |
|
3246 | if not par: | |
3247 | b = textwrap.dedent(block) |
|
3247 | b = textwrap.dedent(block) | |
3248 | self.user_ns['pasted_block'] = b |
|
3248 | self.user_ns['pasted_block'] = b | |
3249 |
|
|
3249 | self.run_cell(b) | |
3250 | else: |
|
3250 | else: | |
3251 | self.user_ns[par] = SList(block.splitlines()) |
|
3251 | self.user_ns[par] = SList(block.splitlines()) | |
3252 | print "Block assigned to '%s'" % par |
|
3252 | print "Block assigned to '%s'" % par |
@@ -112,10 +112,10 b' def test_extract_hist_ranges():' | |||||
112 | def test_magic_rerun(): |
|
112 | def test_magic_rerun(): | |
113 | """Simple test for %rerun (no args -> rerun last line)""" |
|
113 | """Simple test for %rerun (no args -> rerun last line)""" | |
114 | ip = get_ipython() |
|
114 | ip = get_ipython() | |
115 | ip.run_cell("a = 10") |
|
115 | ip.run_cell("a = 10", store_history=True) | |
116 | ip.run_cell("a += 1") |
|
116 | ip.run_cell("a += 1", store_history=True) | |
117 | nt.assert_equal(ip.user_ns["a"], 11) |
|
117 | nt.assert_equal(ip.user_ns["a"], 11) | |
118 | ip.run_cell("%rerun") |
|
118 | ip.run_cell("%rerun", store_history=True) | |
119 | nt.assert_equal(ip.user_ns["a"], 12) |
|
119 | nt.assert_equal(ip.user_ns["a"], 12) | |
120 |
|
120 | |||
121 | def test_timestamp_type(): |
|
121 | def test_timestamp_type(): |
@@ -73,11 +73,11 b' class InteractiveShellTestCase(unittest.TestCase):' | |||||
73 | "Ending a line with semicolon should not cache the returned object (GH-307)" |
|
73 | "Ending a line with semicolon should not cache the returned object (GH-307)" | |
74 | ip = get_ipython() |
|
74 | ip = get_ipython() | |
75 | oldlen = len(ip.user_ns['Out']) |
|
75 | oldlen = len(ip.user_ns['Out']) | |
76 | a = ip.run_cell('1;') |
|
76 | a = ip.run_cell('1;', store_history=True) | |
77 | newlen = len(ip.user_ns['Out']) |
|
77 | newlen = len(ip.user_ns['Out']) | |
78 | self.assertEquals(oldlen, newlen) |
|
78 | self.assertEquals(oldlen, newlen) | |
79 | #also test the default caching behavior |
|
79 | #also test the default caching behavior | |
80 | ip.run_cell('1') |
|
80 | ip.run_cell('1', store_history=True) | |
81 | newlen = len(ip.user_ns['Out']) |
|
81 | newlen = len(ip.user_ns['Out']) | |
82 | self.assertEquals(oldlen+1, newlen) |
|
82 | self.assertEquals(oldlen+1, newlen) | |
83 |
|
83 | |||
@@ -85,7 +85,7 b' class InteractiveShellTestCase(unittest.TestCase):' | |||||
85 | "Verify that In variable grows with user input (GH-284)" |
|
85 | "Verify that In variable grows with user input (GH-284)" | |
86 | ip = get_ipython() |
|
86 | ip = get_ipython() | |
87 | oldlen = len(ip.user_ns['In']) |
|
87 | oldlen = len(ip.user_ns['In']) | |
88 | ip.run_cell('1;') |
|
88 | ip.run_cell('1;', store_history=True) | |
89 | newlen = len(ip.user_ns['In']) |
|
89 | newlen = len(ip.user_ns['In']) | |
90 | self.assertEquals(oldlen+1, newlen) |
|
90 | self.assertEquals(oldlen+1, newlen) | |
91 | self.assertEquals(ip.user_ns['In'][-1],'1;') |
|
91 | self.assertEquals(ip.user_ns['In'][-1],'1;') |
@@ -171,7 +171,7 b' def test_macro_run():' | |||||
171 | cmds = ["a=10", "a+=1", py3compat.doctest_refactor_print("print a"), |
|
171 | cmds = ["a=10", "a+=1", py3compat.doctest_refactor_print("print a"), | |
172 | "%macro test 2-3"] |
|
172 | "%macro test 2-3"] | |
173 | for cmd in cmds: |
|
173 | for cmd in cmds: | |
174 | ip.run_cell(cmd) |
|
174 | ip.run_cell(cmd, store_history=True) | |
175 | nt.assert_equal(ip.user_ns["test"].value, |
|
175 | nt.assert_equal(ip.user_ns["test"].value, | |
176 | py3compat.doctest_refactor_print("a+=1\nprint a\n")) |
|
176 | py3compat.doctest_refactor_print("a+=1\nprint a\n")) | |
177 | with tt.AssertPrints("12"): |
|
177 | with tt.AssertPrints("12"): | |
@@ -316,6 +316,7 b' def check_cpaste(code, should_fail=False):' | |||||
316 | _ip.user_ns['code_ran'] = False |
|
316 | _ip.user_ns['code_ran'] = False | |
317 |
|
317 | |||
318 | src = StringIO() |
|
318 | src = StringIO() | |
|
319 | src.encoding = None # IPython expects stdin to have an encoding attribute | |||
319 | src.write('\n') |
|
320 | src.write('\n') | |
320 | src.write(code) |
|
321 | src.write(code) | |
321 | src.write('\n--\n') |
|
322 | src.write('\n--\n') | |
@@ -325,15 +326,12 b' def check_cpaste(code, should_fail=False):' | |||||
325 | sys.stdin = src |
|
326 | sys.stdin = src | |
326 |
|
327 | |||
327 | try: |
|
328 | try: | |
328 | _ip.magic('cpaste') |
|
329 | context = tt.AssertPrints if should_fail else tt.AssertNotPrints | |
329 | except: |
|
330 | with context("Traceback (most recent call last)"): | |
|
331 | _ip.magic('cpaste') | |||
|
332 | ||||
330 | if not should_fail: |
|
333 | if not should_fail: | |
331 | raise AssertionError("Failure not expected : '%s'" % |
|
334 | assert _ip.user_ns['code_ran'] | |
332 | code) |
|
|||
333 | else: |
|
|||
334 | assert _ip.user_ns['code_ran'] |
|
|||
335 | if should_fail: |
|
|||
336 | raise AssertionError("Failure expected : '%s'" % code) |
|
|||
337 | finally: |
|
335 | finally: | |
338 | sys.stdin = stdin_save |
|
336 | sys.stdin = stdin_save | |
339 |
|
337 |
@@ -309,7 +309,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
309 | self.edit_syntax_error() |
|
309 | self.edit_syntax_error() | |
310 | if not more: |
|
310 | if not more: | |
311 | source_raw = self.input_splitter.source_raw_reset()[1] |
|
311 | source_raw = self.input_splitter.source_raw_reset()[1] | |
312 | self.run_cell(source_raw) |
|
312 | self.run_cell(source_raw, store_history=True) | |
313 |
|
313 | |||
314 | # We are off again... |
|
314 | # We are off again... | |
315 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
315 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
@@ -250,7 +250,7 b' class Kernel(Configurable):' | |||||
250 | shell.run_code(code) |
|
250 | shell.run_code(code) | |
251 | else: |
|
251 | else: | |
252 | # FIXME: the shell calls the exception handler itself. |
|
252 | # FIXME: the shell calls the exception handler itself. | |
253 | shell.run_cell(code) |
|
253 | shell.run_cell(code, store_history=True) | |
254 | except: |
|
254 | except: | |
255 | status = u'error' |
|
255 | status = u'error' | |
256 | # FIXME: this code right now isn't being used yet by default, |
|
256 | # FIXME: this code right now isn't being used yet by default, |
General Comments 0
You need to be logged in to leave comments.
Login now