Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16865e0

Browse files
authored
Simplify and extend the test for multiline repr
`BreakingReprParent` is not really necessary here, testing using lists is easier to understand, and lets us test multiple lengths of list.
1 parent a4e12b3 commit 16865e0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

IPython/lib/tests/test_pretty.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ class BreakingRepr(object):
6868
def __repr__(self):
6969
return "Breaking(\n)"
7070

71-
class BreakingReprParent(object):
72-
def _repr_pretty_(self, p, cycle):
73-
with p.group(4,"TG: ",":"):
74-
p.pretty(BreakingRepr())
75-
7671
class BadRepr(object):
7772

7873
def __repr__(self):
@@ -151,8 +146,12 @@ def test_pprint_break_repr():
151146
"""
152147
Test that p.break_ is used in repr
153148
"""
154-
output = pretty.pretty(BreakingReprParent())
155-
expected = "TG: Breaking(\n ):"
149+
output = pretty.pretty([[BreakingRepr()]])
150+
expected = "[[Breaking(\n )]]"
151+
nt.assert_equal(output, expected)
152+
153+
output = pretty.pretty([[BreakingRepr()]*2])
154+
expected = "[[Breaking(\n ),\n Breaking(\n )]]"
156155
nt.assert_equal(output, expected)
157156

158157
def test_bad_repr():

0 commit comments

Comments
 (0)