##// END OF EJS Templates
Backport PR #4008: Transform code before %prun/%%prun runs...
Thomas Kluyver -
Show More
@@ -181,6 +181,7 b' python-profiler package from non-free.""")'
181 list_all=True, posix=False)
181 list_all=True, posix=False)
182 if cell is not None:
182 if cell is not None:
183 arg_str += '\n' + cell
183 arg_str += '\n' + cell
184 arg_str = self.shell.input_splitter.transform_cell(arg_str)
184 return self._run_with_profiler(arg_str, opts, self.shell.user_ns)
185 return self._run_with_profiler(arg_str, opts, self.shell.user_ns)
185
186
186 def _run_with_profiler(self, code, opts, namespace):
187 def _run_with_profiler(self, code, opts, namespace):
@@ -490,6 +490,21 b' def test_timeit_special_syntax():'
490
490
491
491
492 @dec.skipif(execution.profile is None)
492 @dec.skipif(execution.profile is None)
493 def test_prun_special_syntax():
494 "Test %%prun with IPython special syntax"
495 @register_line_magic
496 def lmagic(line):
497 ip = get_ipython()
498 ip.user_ns['lmagic_out'] = line
499
500 # line mode test
501 _ip.run_line_magic('prun', '-q %lmagic my line')
502 nt.assert_equal(_ip.user_ns['lmagic_out'], 'my line')
503 # cell mode test
504 _ip.run_cell_magic('prun', '-q', '%lmagic my line2')
505 nt.assert_equal(_ip.user_ns['lmagic_out'], 'my line2')
506
507 @dec.skipif(execution.profile is None)
493 def test_prun_quotes():
508 def test_prun_quotes():
494 "Test that prun does not clobber string escapes (GH #1302)"
509 "Test that prun does not clobber string escapes (GH #1302)"
495 _ip.magic(r"prun -q x = '\t'")
510 _ip.magic(r"prun -q x = '\t'")
General Comments 0
You need to be logged in to leave comments. Login now