##// END OF EJS Templates
Merge pull request #1793 from fperez/truncated_repr...
Min RK -
r7090:798c5cd1 merge
parent child Browse files
Show More
@@ -0,0 +1,35 b''
1 """Tests for debugging machinery.
2 """
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2012, The IPython Development Team.
5 #
6 # Distributed under the terms of the Modified BSD License.
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
15 # third-party
16 import nose.tools as nt
17
18 # Our own
19 from IPython.core import debugger
20
21 #-----------------------------------------------------------------------------
22 # Tests
23 #-----------------------------------------------------------------------------
24
25 def test_longer_repr():
26 from repr import repr as trepr
27
28 a = '1234567890'* 7
29 ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'"
30 a_trunc = "'123456789012...8901234567890'"
31 nt.assert_equals(trepr(a), a_trunc)
32 # The creation of our tracer modifies the repr module's repr function
33 # in-place, since that global is used directly by the stdlib's pdb module.
34 t = debugger.Tracer()
35 nt.assert_equals(trepr(a), ar)
@@ -123,6 +123,22 b' class Tracer(object):'
123
123
124 if colors is None:
124 if colors is None:
125 colors = def_colors
125 colors = def_colors
126
127 # The stdlib debugger internally uses a modified repr from the `repr`
128 # module, that limits the length of printed strings to a hardcoded
129 # limit of 30 characters. That much trimming is too aggressive, let's
130 # at least raise that limit to 80 chars, which should be enough for
131 # most interactive uses.
132 try:
133 from repr import aRepr
134 aRepr.maxstring = 80
135 except:
136 # This is only a user-facing convenience, so any error we encounter
137 # here can be warned about but can be otherwise ignored. These
138 # printouts will tell us about problems if this API changes
139 import traceback
140 traceback.print_exc()
141
126 self.debugger = Pdb(colors)
142 self.debugger = Pdb(colors)
127
143
128 def __call__(self):
144 def __call__(self):
General Comments 0
You need to be logged in to leave comments. Login now