mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Factor out SafeReprTests.test_largest_repr().
This commit is contained in:
parent
b0b478dfb3
commit
4b24ea44d3
1 changed files with 8 additions and 6 deletions
|
|
@ -202,15 +202,16 @@ class SafeReprTests(TestBase):
|
|||
d1[2] = d1
|
||||
test(d1, '{1: None, 2: {...}}')
|
||||
|
||||
def test_largest_repr(self):
|
||||
# Find the largest possible repr and ensure it is below our arbitrary
|
||||
# limit (8KB).
|
||||
coll = '-' * (saferepr.maxstring_outer * 2)
|
||||
for limit in reversed(saferepr.maxcollection[1:]):
|
||||
coll = '-' * (SafeRepr.maxstring_outer * 2)
|
||||
for limit in reversed(SafeRepr.maxcollection[1:]):
|
||||
coll = [coll] * (limit * 2)
|
||||
dcoll = {}
|
||||
for i in range(saferepr.maxcollection[0]):
|
||||
dcoll[str(i) * saferepr.maxstring_outer] = coll
|
||||
text = saferepr(dcoll)
|
||||
for i in range(SafeRepr.maxcollection[0]):
|
||||
dcoll[str(i) * SafeRepr.maxstring_outer] = coll
|
||||
text = self.saferepr(dcoll)
|
||||
#try:
|
||||
# text_repr = repr(dcoll)
|
||||
#except MemoryError:
|
||||
|
|
@ -218,7 +219,8 @@ class SafeReprTests(TestBase):
|
|||
# text_repr = ''
|
||||
#print('len(SafeRepr()(dcoll)) = ' + str(len(text)) +
|
||||
# ', len(repr(coll)) = ' + str(len(text_repr)))
|
||||
assert len(text) < 8192
|
||||
|
||||
self.assertLess(len(text), 8192)
|
||||
|
||||
|
||||
class StringTests(TestBase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue