mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 10:15:11 +00:00
Merge branch 'master' of github.com:elijahqi/PySnooper
This commit is contained in:
commit
8f5c2e3f85
4 changed files with 72 additions and 0 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
0
tests/test_depth_inf/__init__.py
Normal file
0
tests/test_depth_inf/__init__.py
Normal file
13
tests/test_depth_inf/factorial.py
Normal file
13
tests/test_depth_inf/factorial.py
Normal file
|
|
@ -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))
|
||||
|
||||
59
tests/test_depth_inf/test_depth_inf.py
Normal file
59
tests/test_depth_inf/test_depth_inf.py
Normal file
|
|
@ -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()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue