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

Skip to content

Commit b0d38e0

Browse files
doerwalterminrk
authored andcommitted
Add test for the indentation fix.
1 parent 2222aa6 commit b0d38e0

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

IPython/lib/tests/test_pretty.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""Tests for IPython.lib.pretty.
2+
"""
3+
#-----------------------------------------------------------------------------
4+
# Copyright (c) 2011, 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+
from __future__ import print_function
15+
16+
# Third-party imports
17+
import nose.tools as nt
18+
19+
# Our own imports
20+
from IPython.lib import pretty
21+
22+
#-----------------------------------------------------------------------------
23+
# Classes and functions
24+
#-----------------------------------------------------------------------------
25+
26+
class MyList(object):
27+
def __init__(self, content):
28+
self.content = content
29+
def _repr_pretty_(self, p, cycle):
30+
if cycle:
31+
p.text("MyList(...)")
32+
else:
33+
with p.group(3, "MyList(", ")"):
34+
for (i, child) in enumerate(self.content):
35+
if i:
36+
p.text(",")
37+
p.breakable()
38+
else:
39+
p.breakable("")
40+
p.pretty(child)
41+
42+
43+
def test_indentation():
44+
"""Test correct indentation in groups"""
45+
count = 40
46+
gotoutput = pretty.pretty(MyList(range(count)))
47+
expectedoutput = "MyList(\n" + ",\n".join(" %d" % i for i in range(count)) + ")"
48+
49+
nt.assert_equals(gotoutput, expectedoutput)

0 commit comments

Comments
 (0)