From bb6f5133d01331f4c4b7fd2244542b08402281ec Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Wed, 24 Apr 2019 12:46:25 +0300 Subject: [PATCH] Add test_lambda --- tests/test_pysnooper.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index 8c0a0e1..4ba26c4 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -233,3 +233,20 @@ def test_confusing_decorator_lines(): ReturnEntry(), ) ) + + +def test_lambda(): + string_io = io.StringIO() + my_function = pysnooper.snoop(string_io)(lambda x: x ** 2) + result = my_function(7) + assert result == 49 + output = string_io.getvalue() + assert_output( + output, + ( + VariableEntry('x', '7'), + CallEntry(source_regex='^my_function = pysnooper.*'), + LineEntry(source_regex='^my_function = pysnooper.*'), + ReturnEntry(source_regex='^my_function = pysnooper.*'), + ) + )