mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Fixed issue #2888. Now the behaviour of pprint when working with nested
structures follows the common sense (and works like in 2.5 and 3.0).
This commit is contained in:
parent
8e1c52ac0e
commit
2da91c375b
4 changed files with 17 additions and 2 deletions
|
@ -170,6 +170,17 @@ class QueryTestCase(unittest.TestCase):
|
|||
for type in [list, list2]:
|
||||
self.assertEqual(pprint.pformat(type(o), indent=4), exp)
|
||||
|
||||
def test_nested_indentations(self):
|
||||
o1 = list(range(10))
|
||||
o2 = dict(first=1, second=2, third=3)
|
||||
o = [o1, o2]
|
||||
expected = """\
|
||||
[ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
{ 'first': 1,
|
||||
'second': 2,
|
||||
'third': 3}]"""
|
||||
self.assertEqual(pprint.pformat(o, indent=4, width=42), expected)
|
||||
|
||||
def test_sorted_dict(self):
|
||||
# Starting in Python 2.5, pprint sorts dict displays by key regardless
|
||||
# of how small the dictionary may be.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue