diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..835a6b7 Binary files /dev/null and b/.DS_Store differ diff --git a/tests/test_depth_inf/__init__.py b/tests/test_depth_inf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_depth_inf/factorial.py b/tests/test_depth_inf/factorial.py new file mode 100644 index 0000000..e7539d3 --- /dev/null +++ b/tests/test_depth_inf/factorial.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 +import pysnooper +# test recursion +@pysnooper.snoop(depth=float("inf"), color = False) +def factorial(x): + """This is a recursive function + to find the factorial of an integer""" + + if x == 1: + return 1 + else: + return (x * factorial(x-1)) + diff --git a/tests/test_depth_inf/test_depth_inf.py b/tests/test_depth_inf/test_depth_inf.py new file mode 100644 index 0000000..c8e904b --- /dev/null +++ b/tests/test_depth_inf/test_depth_inf.py @@ -0,0 +1,59 @@ +# Copyright 2019 Ram Rachum and collaborators. +# This program is distributed under the MIT license. + +import io +import textwrap +import threading +import types +import os +import sys + +from pysnooper.utils import truncate +import pytest + +import pysnooper +from pysnooper.variables import needs_parentheses +from ..utils import (assert_output, assert_sample_output, VariableEntry, + CallEntry, LineEntry, ReturnEntry, OpcodeEntry, + ReturnValueEntry, ExceptionEntry, ExceptionValueEntry, + SourcePathEntry, CallEndedByExceptionEntry, + ElapsedTimeEntry) +from .. import mini_toolbox +from . import factorial + + +def test_multiple_files(): + with mini_toolbox.OutputCapturer(stdout=False, + stderr=True) as output_capturer: + result = factorial.factorial(3) + assert result == 6 + output = output_capturer.string_io.getvalue() + assert_output( + output, + ( + SourcePathEntry(source_path_regex=r'.*factorial\.py$'), + VariableEntry('x', '3'), + CallEntry(), + LineEntry(), + LineEntry(), + VariableEntry('x', '2'), + CallEntry(), + LineEntry(), + LineEntry(), + VariableEntry('x', '1'), + CallEntry(), + LineEntry(), + LineEntry(), + ReturnEntry(), + ReturnValueEntry('1'), + ElapsedTimeEntry(), + ReturnEntry(), + ReturnValueEntry('2'), + ElapsedTimeEntry(), + ReturnEntry(), + ReturnValueEntry('6'), + ElapsedTimeEntry() + ) + ) + +