From ec7687fab3e33ac084fe1be2b16e1c1144aa06c5 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Fri, 26 Apr 2019 12:53:46 +0300 Subject: [PATCH] Add test_single_variable_no_comma --- tests/test_pysnooper.py | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index ea4ae4b..5b2fbea 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -94,6 +94,48 @@ def test_variables(): ) +def test_single_variable_no_comma(): + + class Foo(object): + def __init__(self): + self.x = 2 + + def square(self): + self.x **= 2 + + @pysnooper.snoop(variables='foo') + def my_function(): + foo = Foo() + for i in range(2): + foo.square() + + with sys_tools.OutputCapturer(stdout=False, + stderr=True) as output_capturer: + result = my_function() + assert result is None + output = output_capturer.string_io.getvalue() + assert_output( + output, + ( + VariableEntry('Foo'), + CallEntry('def my_function():'), + LineEntry('foo = Foo()'), + VariableEntry('foo'), + LineEntry(), + VariableEntry('i', '0'), + LineEntry(), + LineEntry(), + VariableEntry('i', '1'), + LineEntry(), + LineEntry(), + ReturnEntry(), + ReturnValueEntry('None') + ) + ) + + + + def test_depth(): string_io = io.StringIO()