diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index b321d95..a4219fc 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -50,6 +50,36 @@ def test_string_io(): ) +def test_relative_time(): + string_io = io.StringIO() + + @pysnooper.snoop(string_io, relative_time=True) + def my_function(foo): + x = 7 + y = 8 + return y + x + + result = my_function('baba') + assert result == 15 + output = string_io.getvalue() + assert_output( + output, + ( + SourcePathEntry(), + VariableEntry('foo', value_regex="u?'baba'"), + CallEntry('def my_function(foo):'), + LineEntry('x = 7'), + VariableEntry('x', '7'), + LineEntry('y = 8'), + VariableEntry('y', '8'), + LineEntry('return y + x'), + ReturnEntry('return y + x'), + ReturnValueEntry('15'), + ElapsedTimeEntry(), + ) + ) + + def test_thread_info(): @pysnooper.snoop(thread_info=True)