diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index ea59552..bd0ec77 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -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('^$') +repr_instance = reprlib.Repr() +repr_instance.maxother = 100 + def get_shortish_repr(item): r = reprlib.repr(item) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index 5b2fbea..8f25373 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -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():