##// END OF EJS Templates
Merge pull request #10993 from minrk/exec-count...
Thomas Kluyver -
r24140:35a4f43a merge
parent child Browse files
Show More
@@ -2696,6 +2696,8 b' class InteractiveShell(SingletonConfigurable):'
2696 result.execution_count = self.execution_count
2696 result.execution_count = self.execution_count
2697
2697
2698 def error_before_exec(value):
2698 def error_before_exec(value):
2699 if store_history:
2700 self.execution_count += 1
2699 result.error_before_exec = value
2701 result.error_before_exec = value
2700 self.last_execution_succeeded = False
2702 self.last_execution_succeeded = False
2701 self.last_execution_result = result
2703 self.last_execution_result = result
@@ -2760,14 +2762,10 b' class InteractiveShell(SingletonConfigurable):'
2760 return error_before_exec(e)
2762 return error_before_exec(e)
2761 except IndentationError as e:
2763 except IndentationError as e:
2762 self.showindentationerror()
2764 self.showindentationerror()
2763 if store_history:
2764 self.execution_count += 1
2765 return error_before_exec(e)
2765 return error_before_exec(e)
2766 except (OverflowError, SyntaxError, ValueError, TypeError,
2766 except (OverflowError, SyntaxError, ValueError, TypeError,
2767 MemoryError) as e:
2767 MemoryError) as e:
2768 self.showsyntaxerror()
2768 self.showsyntaxerror()
2769 if store_history:
2770 self.execution_count += 1
2771 return error_before_exec(e)
2769 return error_before_exec(e)
2772
2770
2773 # Apply AST transformations
2771 # Apply AST transformations
@@ -2775,8 +2773,6 b' class InteractiveShell(SingletonConfigurable):'
2775 code_ast = self.transform_ast(code_ast)
2773 code_ast = self.transform_ast(code_ast)
2776 except InputRejected as e:
2774 except InputRejected as e:
2777 self.showtraceback()
2775 self.showtraceback()
2778 if store_history:
2779 self.execution_count += 1
2780 return error_before_exec(e)
2776 return error_before_exec(e)
2781
2777
2782 # Give the displayhook a reference to our ExecutionResult so it
2778 # Give the displayhook a reference to our ExecutionResult so it
@@ -922,3 +922,14 b' def wrn():'
922 with tt.AssertNotPrints("I AM A WARNING"):
922 with tt.AssertNotPrints("I AM A WARNING"):
923 ip.run_cell("wrn()")
923 ip.run_cell("wrn()")
924 ip.run_cell("del wrn")
924 ip.run_cell("del wrn")
925
926
927 def test_custom_exc_count():
928 hook = mock.Mock(return_value=None)
929 ip.set_custom_exc((SyntaxError,), hook)
930 before = ip.execution_count
931 ip.run_cell("def foo()", store_history=True)
932 # restore default excepthook
933 ip.set_custom_exc((), None)
934 nt.assert_equal(hook.call_count, 1)
935 nt.assert_equal(ip.execution_count, before + 1)
General Comments 0
You need to be logged in to leave comments. Login now