From 2ac382f8563452ce982665a39c8abd99106cc9ac Mon Sep 17 00:00:00 2001 From: iory Date: Sat, 18 Apr 2020 09:35:07 +0900 Subject: [PATCH] Fixed test for elapsed time entry --- tests/samples/indentation.py | 1 + tests/samples/recursion.py | 55 ++++++++++--------- .../test_multiple_files.py | 4 +- tests/test_pysnooper.py | 1 + 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/tests/samples/indentation.py b/tests/samples/indentation.py index 65cb7b4..60f073b 100644 --- a/tests/samples/indentation.py +++ b/tests/samples/indentation.py @@ -38,6 +38,7 @@ Source path:... Whatever Return value:.. None 21:10:42.299509 return 19 f5() Return value:.. None + Total elapsed time: 00:00:00.000134 21:10:42.299577 return 10 f3() Return value:.. None 21:10:42.299627 return 6 f2() diff --git a/tests/samples/recursion.py b/tests/samples/recursion.py index 7edbaac..f1529ed 100644 --- a/tests/samples/recursion.py +++ b/tests/samples/recursion.py @@ -18,46 +18,49 @@ def main(): expected_output = ''' Source path:... Whatever Starting var:.. x = 4 -20:28:17.875295 call 5 def factorial(x): -20:28:17.875509 line 6 if x <= 1: -20:28:17.875550 line 8 return mul(x, factorial(x - 1)) +09:31:32.691599 call 5 def factorial(x): +09:31:32.691722 line 6 if x <= 1: +09:31:32.691746 line 8 return mul(x, factorial(x - 1)) Starting var:.. x = 3 - 20:28:17.875624 call 5 def factorial(x): - 20:28:17.875668 line 6 if x <= 1: - 20:28:17.875703 line 8 return mul(x, factorial(x - 1)) + 09:31:32.691781 call 5 def factorial(x): + 09:31:32.691806 line 6 if x <= 1: + 09:31:32.691823 line 8 return mul(x, factorial(x - 1)) Starting var:.. x = 2 - 20:28:17.875771 call 5 def factorial(x): - 20:28:17.875813 line 6 if x <= 1: - 20:28:17.875849 line 8 return mul(x, factorial(x - 1)) + 09:31:32.691852 call 5 def factorial(x): + 09:31:32.691875 line 6 if x <= 1: + 09:31:32.691892 line 8 return mul(x, factorial(x - 1)) Starting var:.. x = 1 - 20:28:17.875913 call 5 def factorial(x): - 20:28:17.875953 line 6 if x <= 1: - 20:28:17.875987 line 7 return 1 - 20:28:17.876021 return 7 return 1 + 09:31:32.691918 call 5 def factorial(x): + 09:31:32.691941 line 6 if x <= 1: + 09:31:32.691961 line 7 return 1 + 09:31:32.691978 return 7 return 1 Return value:.. 1 + Total elapsed time: 00:00:00.000092 Starting var:.. a = 2 Starting var:.. b = 1 - 20:28:17.876111 call 11 def mul(a, b): - 20:28:17.876151 line 12 return a * b - 20:28:17.876190 return 12 return a * b + 09:31:32.692025 call 11 def mul(a, b): + 09:31:32.692055 line 12 return a * b + 09:31:32.692075 return 12 return a * b Return value:.. 2 - 20:28:17.876235 return 8 return mul(x, factorial(x - 1)) + 09:31:32.692102 return 8 return mul(x, factorial(x - 1)) Return value:.. 2 + Total elapsed time: 00:00:00.000283 Starting var:.. a = 3 Starting var:.. b = 2 - 20:28:17.876320 call 11 def mul(a, b): - 20:28:17.876359 line 12 return a * b - 20:28:17.876397 return 12 return a * b + 09:31:32.692147 call 11 def mul(a, b): + 09:31:32.692174 line 12 return a * b + 09:31:32.692193 return 12 return a * b Return value:.. 6 - 20:28:17.876442 return 8 return mul(x, factorial(x - 1)) + 09:31:32.692216 return 8 return mul(x, factorial(x - 1)) Return value:.. 6 + Total elapsed time: 00:00:00.000468 Starting var:.. a = 4 Starting var:.. b = 6 - 20:28:17.876525 call 11 def mul(a, b): - 20:28:17.876563 line 12 return a * b - 20:28:17.876601 return 12 return a * b + 09:31:32.692259 call 11 def mul(a, b): + 09:31:32.692285 line 12 return a * b + 09:31:32.692304 return 12 return a * b Return value:.. 24 -20:28:17.876646 return 8 return mul(x, factorial(x - 1)) +09:31:32.692326 return 8 return mul(x, factorial(x - 1)) Return value:.. 24 -Total elapsed time: 00:00:00.000651 +Total elapsed time: 00:00:00.000760 ''' diff --git a/tests/test_multiple_files/test_multiple_files.py b/tests/test_multiple_files/test_multiple_files.py index 5bd233a..e217ce4 100644 --- a/tests/test_multiple_files/test_multiple_files.py +++ b/tests/test_multiple_files/test_multiple_files.py @@ -15,7 +15,8 @@ import pysnooper from pysnooper.variables import needs_parentheses from ..utils import (assert_output, assert_sample_output, VariableEntry, CallEntry, LineEntry, ReturnEntry, OpcodeEntry, - ReturnValueEntry, ExceptionEntry, SourcePathEntry) + ReturnValueEntry, ExceptionEntry, SourcePathEntry, + ElapsedTimeEntry) from .. import mini_toolbox from .multiple_files import foo @@ -45,6 +46,7 @@ def test_multiple_files(): LineEntry(), ReturnEntry(), ReturnValueEntry(), + ElapsedTimeEntry(), ) ) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index 2140ca5..d4dd5f4 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -1544,6 +1544,7 @@ def test_class_with_decorated_method_and_snoop_applied_to_method(normalize): LineEntry('return y + self.x'), ReturnEntry('return y + self.x'), ReturnValueEntry('15'), + ElapsedTimeEntry(), VariableEntry('result', '15'), LineEntry('return result'), ReturnEntry('return result'),