summaryrefslogtreecommitdiff
path: root/Lib/test/test_pprint.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-20 20:57:15 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-20 20:57:15 +0200
commitfe3dc376fa73fce563be26417ea763b05115990b (patch)
tree286e2d24f64a15e2aecda42f8b43070a02a045af /Lib/test/test_pprint.py
parentf65d1d3b0241f79715df04192e21144672704fd7 (diff)
downloadcpython-git-fe3dc376fa73fce563be26417ea763b05115990b.tar.gz
Issue #19104: pprint now produces evaluable output for wrapped strings.
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r--Lib/test/test_pprint.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 3d364c4595..ad6a7a144a 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -536,9 +536,10 @@ frozenset2({0,
# pprint tries to wrap strings intelligently
fox = 'the quick brown fox jumped over a lazy dog'
self.assertEqual(pprint.pformat(fox, width=20), """\
-'the quick brown '
-'fox jumped over '
-'a lazy dog'""")
+('the quick '
+ 'brown fox '
+ 'jumped over a '
+ 'lazy dog')""")
self.assertEqual(pprint.pformat({'a': 1, 'b': fox, 'c': 2},
width=26), """\
{'a': 1,
@@ -552,12 +553,12 @@ frozenset2({0,
# - non-ASCII is allowed
# - an apostrophe doesn't disrupt the pprint
special = "Portons dix bons \"whiskys\"\nà l'avocat goujat\t qui fumait au zoo"
- self.assertEqual(pprint.pformat(special, width=20), """\
-'Portons dix bons '
-'"whiskys"\\n'
-"à l'avocat "
-'goujat\\t qui '
-'fumait au zoo'""")
+ self.assertEqual(pprint.pformat(special, width=21), """\
+('Portons dix '
+ 'bons "whiskys"\\n'
+ "à l'avocat "
+ 'goujat\\t qui '
+ 'fumait au zoo')""")
# An unwrappable string is formatted as its repr
unwrappable = "x" * 100
self.assertEqual(pprint.pformat(unwrappable, width=80), repr(unwrappable))
@@ -566,7 +567,9 @@ frozenset2({0,
special *= 10
for width in range(3, 40):
formatted = pprint.pformat(special, width=width)
- self.assertEqual(eval("(" + formatted + ")"), special)
+ self.assertEqual(eval(formatted), special)
+ formatted = pprint.pformat([special] * 2, width=width)
+ self.assertEqual(eval(formatted), [special] * 2)
def test_compact(self):
o = ([list(range(i * i)) for i in range(5)] +