MCPcopy
hub / github.com/cool-RR/PySnooper / ElapsedTimeEntry

Class ElapsedTimeEntry

tests/utils.py:95–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93
94
95class ElapsedTimeEntry(_BaseEntry):
96 def __init__(self, elapsed_time_value=None, tolerance=0.2, prefix='',
97 min_python_version=None, max_python_version=None):
98 _BaseEntry.__init__(self, prefix=prefix,
99 min_python_version=min_python_version,
100 max_python_version=max_python_version)
101 self.line_pattern = re.compile(
102 r"""^%s(?P<indent>(?: {4})*)Elapsed time: (?P<time>.*)""" % (
103 re.escape(self.prefix),
104 )
105 )
106 self.elapsed_time_value = elapsed_time_value
107 self.tolerance = tolerance
108
109 def check(self, s):
110 match = self.line_pattern.match(s)
111 if not match:
112 return False
113 timedelta = pysnooper.pycompat.timedelta_parse(match.group('time'))
114 if self.elapsed_time_value:
115 return abs(timedelta.total_seconds() - self.elapsed_time_value) \
116 <= self.tolerance
117 else:
118 return True
119
120
121

Callers 15

test_string_ioFunction · 0.85
test_relative_timeFunction · 0.85
test_thread_infoFunction · 0.85
test_multi_thread_infoFunction · 0.85
test_callableFunction · 0.85
test_watchFunction · 0.85
test_watch_explodeFunction · 0.85
test_variables_classesFunction · 0.85
test_long_variableFunction · 0.85

Calls

no outgoing calls

Tested by 15

test_string_ioFunction · 0.68
test_relative_timeFunction · 0.68
test_thread_infoFunction · 0.68
test_multi_thread_infoFunction · 0.68
test_callableFunction · 0.68
test_watchFunction · 0.68
test_watch_explodeFunction · 0.68
test_variables_classesFunction · 0.68
test_long_variableFunction · 0.68