Show More
@@ -1044,6 +1044,13 b' python-profiler package from non-free.""")' | |||||
1044 | ast_setup = self.shell.transform_ast(ast_setup) |
|
1044 | ast_setup = self.shell.transform_ast(ast_setup) | |
1045 | ast_stmt = self.shell.transform_ast(ast_stmt) |
|
1045 | ast_stmt = self.shell.transform_ast(ast_stmt) | |
1046 |
|
1046 | |||
|
1047 | # Check that these compile to valid Python code *outside* the timer func | |||
|
1048 | # Invalid code may become valid when put inside the function & loop, | |||
|
1049 | # which messes up error messages. | |||
|
1050 | # https://github.com/ipython/ipython/issues/10636 | |||
|
1051 | self.shell.compile(ast_setup, "<magic-timeit-setup>", "exec") | |||
|
1052 | self.shell.compile(ast_stmt, "<magic-timeit-stmt>", "exec") | |||
|
1053 | ||||
1047 | # This codestring is taken from timeit.template - we fill it in as an |
|
1054 | # This codestring is taken from timeit.template - we fill it in as an | |
1048 | # AST, so that we can apply our AST transformations to the user code |
|
1055 | # AST, so that we can apply our AST transformations to the user code | |
1049 | # without affecting the timing code. |
|
1056 | # without affecting the timing code. |
@@ -576,6 +576,10 b' def test_timeit_return_quiet():' | |||||
576 | res = _ip.run_line_magic('timeit', '-n1 -r1 -q -o 1') |
|
576 | res = _ip.run_line_magic('timeit', '-n1 -r1 -q -o 1') | |
577 | assert (res is not None) |
|
577 | assert (res is not None) | |
578 |
|
578 | |||
|
579 | def test_timeit_invalid_return(): | |||
|
580 | with nt.assert_raises_regexp(SyntaxError, "outside function"): | |||
|
581 | _ip.run_line_magic('timeit', 'return') | |||
|
582 | ||||
579 | @dec.skipif(execution.profile is None) |
|
583 | @dec.skipif(execution.profile is None) | |
580 | def test_prun_special_syntax(): |
|
584 | def test_prun_special_syntax(): | |
581 | "Test %%prun with IPython special syntax" |
|
585 | "Test %%prun with IPython special syntax" |
General Comments 0
You need to be logged in to leave comments.
Login now