mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-07-20 01:44:10 +00:00
PR feedback:
Swap imports Raise maxother locally Demo long variable output
This commit is contained in:
parent
a5e420a3ab
commit
4ec976bd14
2 changed files with 27 additions and 2 deletions
|
|
@ -7,14 +7,17 @@ import collections
|
|||
import datetime as datetime_module
|
||||
import itertools
|
||||
try:
|
||||
import repr as reprlib
|
||||
except ImportError:
|
||||
import reprlib
|
||||
except ImportError:
|
||||
import repr as reprlib
|
||||
|
||||
from .third_party import six
|
||||
|
||||
ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
|
||||
|
||||
repr_instance = reprlib.Repr()
|
||||
repr_instance.maxother = 100
|
||||
|
||||
|
||||
def get_shortish_repr(item):
|
||||
r = reprlib.repr(item)
|
||||
|
|
|
|||
|
|
@ -134,6 +134,28 @@ def test_single_variable_no_comma():
|
|||
)
|
||||
|
||||
|
||||
def test_long_variable():
|
||||
@pysnooper.snoop()
|
||||
def my_function():
|
||||
foo = list(range(1000))
|
||||
return foo
|
||||
|
||||
with sys_tools.OutputCapturer(stdout=False,
|
||||
stderr=True) as output_capturer:
|
||||
result = my_function()
|
||||
assert result == list(range(1000))
|
||||
output = output_capturer.string_io.getvalue()
|
||||
assert_output(
|
||||
output,
|
||||
(
|
||||
CallEntry('def my_function():'),
|
||||
LineEntry('foo = list(range(1000))'),
|
||||
VariableEntry('foo', '[0, 1, 2, 3, 4, 5, ...]'),
|
||||
LineEntry(),
|
||||
ReturnEntry(),
|
||||
ReturnValueEntry('[0, 1, 2, 3, 4, 5, ...]')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_depth():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue