Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_pprint.py @ 86127:a3d09c19bb93
merge with 3.3
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 06 Oct 2013 19:24:00 +0200 |
| parents | ae0306c8f7a3 |
| children |
| rev | line source |
|---|---|
|
82919
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
1 # -*- coding: utf-8 -*- |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
2 |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
3 import pprint |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
47080
diff
changeset
|
4 import test.support |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
5 import unittest |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
6 import test.test_set |
|
57340
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
7 import random |
|
64583
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
8 import collections |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
9 import itertools |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
10 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
11 # list, tuple and dict subclasses that do or don't overwrite __repr__ |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
12 class list2(list): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
13 pass |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
14 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
15 class list3(list): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
16 def __repr__(self): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
17 return list.__repr__(self) |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
18 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
19 class tuple2(tuple): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
20 pass |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
21 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
22 class tuple3(tuple): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
23 def __repr__(self): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
24 return tuple.__repr__(self) |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
25 |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
26 class set2(set): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
27 pass |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
28 |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
29 class set3(set): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
30 def __repr__(self): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
31 return set.__repr__(self) |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
32 |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
33 class frozenset2(frozenset): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
34 pass |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
35 |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
36 class frozenset3(frozenset): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
37 def __repr__(self): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
38 return frozenset.__repr__(self) |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
39 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
40 class dict2(dict): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
41 pass |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
42 |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
43 class dict3(dict): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
44 def __repr__(self): |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
45 return dict.__repr__(self) |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
46 |
|
57340
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
47 class Unorderable: |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
48 def __repr__(self): |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
49 return str(id(self)) |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
50 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
51 class QueryTestCase(unittest.TestCase): |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
52 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
53 def setUp(self): |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41575
diff
changeset
|
54 self.a = list(range(100)) |
|
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41575
diff
changeset
|
55 self.b = list(range(200)) |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
56 self.a[-12] = self.b |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
57 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
58 def test_basic(self): |
|
24957
dc66eb4cd17a
Standardize behavior: no docstrings in test functions.
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
59 # Verify .isrecursive() and .isreadable() w/o recursion |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
60 pp = pprint.PrettyPrinter() |
|
42050
ca693f4fd05d
Simplify various spots where: str() is called on something
Walter Dörwald <walter@livinglogic.de>
parents:
41642
diff
changeset
|
61 for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, "yaddayadda", |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
62 self.a, self.b): |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
63 # module-level convenience functions |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
64 self.assertFalse(pprint.isrecursive(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
65 "expected not isrecursive for %r" % (safe,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
66 self.assertTrue(pprint.isreadable(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
67 "expected isreadable for %r" % (safe,)) |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
68 # PrettyPrinter methods |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
69 self.assertFalse(pp.isrecursive(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
70 "expected not isrecursive for %r" % (safe,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
71 self.assertTrue(pp.isreadable(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
72 "expected isreadable for %r" % (safe,)) |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
73 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
74 def test_knotted(self): |
|
24957
dc66eb4cd17a
Standardize behavior: no docstrings in test functions.
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
75 # Verify .isrecursive() and .isreadable() w/ recursion |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
76 # Tie a knot. |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
77 self.b[67] = self.a |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
78 # Messy dict. |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
79 self.d = {} |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
80 self.d[0] = self.d[1] = self.d[2] = self.d |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
81 |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
82 pp = pprint.PrettyPrinter() |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
83 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
84 for icky in self.a, self.b, self.d, (self.d, self.d): |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
85 self.assertTrue(pprint.isrecursive(icky), "expected isrecursive") |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
86 self.assertFalse(pprint.isreadable(icky), "expected not isreadable") |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
87 self.assertTrue(pp.isrecursive(icky), "expected isrecursive") |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
88 self.assertFalse(pp.isreadable(icky), "expected not isreadable") |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
89 |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
90 # Break the cycles. |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
91 self.d.clear() |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
92 del self.a[:] |
|
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
93 del self.b[:] |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
94 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
95 for safe in self.a, self.b, self.d, (self.d, self.d): |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
96 # module-level convenience functions |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
97 self.assertFalse(pprint.isrecursive(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
98 "expected not isrecursive for %r" % (safe,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
99 self.assertTrue(pprint.isreadable(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
100 "expected isreadable for %r" % (safe,)) |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
101 # PrettyPrinter methods |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
102 self.assertFalse(pp.isrecursive(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
103 "expected not isrecursive for %r" % (safe,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
104 self.assertTrue(pp.isreadable(safe), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
105 "expected isreadable for %r" % (safe,)) |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
106 |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
107 def test_unreadable(self): |
|
24957
dc66eb4cd17a
Standardize behavior: no docstrings in test functions.
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
108 # Not recursive but not readable anyway |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
109 pp = pprint.PrettyPrinter() |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
110 for unreadable in type(3), pprint, pprint.isrecursive: |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
111 # module-level convenience functions |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
112 self.assertFalse(pprint.isrecursive(unreadable), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
113 "expected not isrecursive for %r" % (unreadable,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
114 self.assertFalse(pprint.isreadable(unreadable), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
115 "expected not isreadable for %r" % (unreadable,)) |
|
26930
32e4c7753416
Make sure PrettyPrinter methods that mirror the module-level
Fred Drake <fdrake@acm.org>
parents:
24957
diff
changeset
|
116 # PrettyPrinter methods |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
117 self.assertFalse(pp.isrecursive(unreadable), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
118 "expected not isrecursive for %r" % (unreadable,)) |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
119 self.assertFalse(pp.isreadable(unreadable), |
|
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
120 "expected not isreadable for %r" % (unreadable,)) |
|
17820
4bcf88e4abff
SF bug[ #423781: pprint.isrecursive() broken.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
121 |
|
17828
26745053f840
pprint's workhorse _safe_repr() function took time quadratic in the # of
Tim Peters <tim.peters@gmail.com>
parents:
17827
diff
changeset
|
122 def test_same_as_repr(self): |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
123 # Simple objects, small containers and classes that overwrite __repr__ |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
124 # For those the result should be the same as repr(). |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
125 # Ahem. The docs don't say anything about that -- this appears to |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
126 # be testing an implementation quirk. Starting in Python 2.5, it's |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
127 # not true for dicts: pprint always sorts dicts by key now; before, |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
128 # it sorted a dict display if and only if the display required |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
129 # multiple lines. For that reason, dicts with more than one element |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
130 # aren't tested here. |
|
42050
ca693f4fd05d
Simplify various spots where: str() is called on something
Walter Dörwald <walter@livinglogic.de>
parents:
41642
diff
changeset
|
131 for simple in (0, 0, 0+0j, 0.0, "", b"", |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
132 (), tuple2(), tuple3(), |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
133 [], list2(), list3(), |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
134 set(), set2(), set3(), |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
135 frozenset(), frozenset2(), frozenset3(), |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
136 {}, dict2(), dict3(), |
|
58476
c10ace5b76ce
Merged revisions 77729 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
57340
diff
changeset
|
137 self.assertTrue, pprint, |
|
42050
ca693f4fd05d
Simplify various spots where: str() is called on something
Walter Dörwald <walter@livinglogic.de>
parents:
41642
diff
changeset
|
138 -6, -6, -6-6j, -1.5, "x", b"x", (3,), [3], {3: 6}, |
|
52892
792bb885029f
Merged revisions 70712,70714,70764-70765,70769-70771,70773,70776-70777,70788-70789,70824,70828,70832,70836,70842,70851,70855,70857,70866-70872,70883,70885,70893-70894,70896-70897,70903,70905-70907,70915,70927,70933,70951,70960,70962-70964,70998,71001,71006,71008,71010-71011,71019,71037,71056,71094,71101-71103,71106,71119,71123,71149-71150,71203,71212,71214-71217,71221,71240 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48493
diff
changeset
|
139 (1,2), [3,4], {5: 6}, |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
140 tuple2((1,2)), tuple3((1,2)), tuple3(range(100)), |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
141 [3,4], list2([3,4]), list3([3,4]), list3(range(100)), |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
142 set({7}), set2({7}), set3({7}), |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
143 frozenset({8}), frozenset2({8}), frozenset3({8}), |
|
52892
792bb885029f
Merged revisions 70712,70714,70764-70765,70769-70771,70773,70776-70777,70788-70789,70824,70828,70832,70836,70842,70851,70855,70857,70866-70872,70883,70885,70893-70894,70896-70897,70903,70905-70907,70915,70927,70933,70951,70960,70962-70964,70998,71001,71006,71008,71010-71011,71019,71037,71056,71094,71101-71103,71106,71119,71123,71149-71150,71203,71212,71214-71217,71221,71240 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
48493
diff
changeset
|
144 dict2({5: 6}), dict3({5: 6}), |
|
17828
26745053f840
pprint's workhorse _safe_repr() function took time quadratic in the # of
Tim Peters <tim.peters@gmail.com>
parents:
17827
diff
changeset
|
145 range(10, -11, -1) |
|
26745053f840
pprint's workhorse _safe_repr() function took time quadratic in the # of
Tim Peters <tim.peters@gmail.com>
parents:
17827
diff
changeset
|
146 ): |
|
26745053f840
pprint's workhorse _safe_repr() function took time quadratic in the # of
Tim Peters <tim.peters@gmail.com>
parents:
17827
diff
changeset
|
147 native = repr(simple) |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
148 self.assertEqual(pprint.pformat(simple), native) |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
149 self.assertEqual(pprint.pformat(simple, width=1, indent=0) |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
150 .replace('\n', ' '), native) |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
151 self.assertEqual(pprint.saferepr(simple), native) |
|
17827
0b3da99824c7
Convert the pprint test to use PyUnit.
Fred Drake <fdrake@acm.org>
parents:
17820
diff
changeset
|
152 |
|
21061
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
153 def test_basic_line_wrap(self): |
|
24957
dc66eb4cd17a
Standardize behavior: no docstrings in test functions.
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
154 # verify basic line-wrapping operation |
|
21061
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
155 o = {'RPM_cal': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
156 'RPM_cal2': 48059, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
157 'Speed_cal': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
158 'controldesk_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
159 'main_code_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
160 'read_io_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
161 'write_io_runtime_us': 43690} |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
162 exp = """\ |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
163 {'RPM_cal': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
164 'RPM_cal2': 48059, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
165 'Speed_cal': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
166 'controldesk_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
167 'main_code_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
168 'read_io_runtime_us': 0, |
|
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
169 'write_io_runtime_us': 43690}""" |
|
31084
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
170 for type in [dict, dict2]: |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
171 self.assertEqual(pprint.pformat(type(o)), exp) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
172 |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
173 o = range(100) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
174 exp = '[%s]' % ',\n '.join(map(str, o)) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
175 for type in [list, list2]: |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
176 self.assertEqual(pprint.pformat(type(o)), exp) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
177 |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
178 o = tuple(range(100)) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
179 exp = '(%s)' % ',\n '.join(map(str, o)) |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
180 for type in [tuple, tuple2]: |
|
e3025fe70d8b
Patch #750542: pprint now will pretty print subclasses of list, tuple
Walter Dörwald <walter@livinglogic.de>
parents:
26930
diff
changeset
|
181 self.assertEqual(pprint.pformat(type(o)), exp) |
|
21061
1802a9edb4ee
__format(): Applied SF patch #482003 by Skip to fix multiline dict
Barry Warsaw <barry@python.org>
parents:
20013
diff
changeset
|
182 |
|
31085
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
183 # indent parameter |
|
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
184 o = range(100) |
|
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
185 exp = '[ %s]' % ',\n '.join(map(str, o)) |
|
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
186 for type in [list, list2]: |
|
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
187 self.assertEqual(pprint.pformat(type(o), indent=4), exp) |
|
a2f6c6a67f24
Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
Walter Dörwald <walter@livinglogic.de>
parents:
31084
diff
changeset
|
188 |
|
48493
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
189 def test_nested_indentations(self): |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
190 o1 = list(range(10)) |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
191 o2 = dict(first=1, second=2, third=3) |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
192 o = [o1, o2] |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
193 expected = """\ |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
194 [ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
195 { 'first': 1, |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
196 'second': 2, |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
197 'third': 3}]""" |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
198 self.assertEqual(pprint.pformat(o, indent=4, width=42), expected) |
|
9ebd3f385575
Merged revisions 64446,64490,64495,64526,64567 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47201
diff
changeset
|
199 |
|
38546
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
200 def test_sorted_dict(self): |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
201 # Starting in Python 2.5, pprint sorts dict displays by key regardless |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
202 # of how small the dictionary may be. |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
203 # Before the change, on 32-bit Windows pformat() gave order |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
204 # 'a', 'c', 'b' here, so this test failed. |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
205 d = {'a': 1, 'b': 1, 'c': 1} |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
206 self.assertEqual(pprint.pformat(d), "{'a': 1, 'b': 1, 'c': 1}") |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
207 self.assertEqual(pprint.pformat([d, d]), |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
208 "[{'a': 1, 'b': 1, 'c': 1}, {'a': 1, 'b': 1, 'c': 1}]") |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
209 |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
210 # The next one is kind of goofy. The sorted order depends on the |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
211 # alphabetic order of type names: "int" < "str" < "tuple". Before |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
212 # Python 2.5, this was in the test_same_as_repr() test. It's worth |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
213 # keeping around for now because it's one of few tests of pprint |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
214 # against a crazy mix of types. |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
215 self.assertEqual(pprint.pformat({"xy\tab\n": (3,), 5: [[]], (): {}}), |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
216 r"{5: [[]], 'xy\tab\n': (3,), (): {}}") |
|
2eb8be0f8731
pprint functions used to sort a dict (by key) if and only if
Tim Peters <tim.peters@gmail.com>
parents:
31515
diff
changeset
|
217 |
|
64583
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
218 def test_ordered_dict(self): |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
219 words = 'the quick brown fox jumped over a lazy dog'.split() |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
220 d = collections.OrderedDict(zip(words, itertools.count())) |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
221 self.assertEqual(pprint.pformat(d), |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
222 """\ |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
223 {'the': 0, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
224 'quick': 1, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
225 'brown': 2, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
226 'fox': 3, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
227 'jumped': 4, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
228 'over': 5, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
229 'a': 6, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
230 'lazy': 7, |
|
9659e8c40079
Have pprint() respect the order in an OrderedDict.
Raymond Hettinger <python@rcn.com>
parents:
58476
diff
changeset
|
231 'dog': 8}""") |
|
22766
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
232 def test_subclassing(self): |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
233 o = {'names with spaces': 'should be presented using repr()', |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
234 'others.should.not.be': 'like.this'} |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
235 exp = """\ |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
236 {'names with spaces': 'should be presented using repr()', |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
237 others.should.not.be: like.this}""" |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
238 self.assertEqual(DottedPrettyPrinter().pformat(o), exp) |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
239 |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
240 def test_set_reprs(self): |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
241 self.assertEqual(pprint.pformat(set()), 'set()') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
242 self.assertEqual(pprint.pformat(set(range(3))), '{0, 1, 2}') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
243 self.assertEqual(pprint.pformat(set(range(7)), width=20), '''\ |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
244 {0, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
245 1, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
246 2, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
247 3, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
248 4, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
249 5, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
250 6}''') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
251 self.assertEqual(pprint.pformat(set2(range(7)), width=20), '''\ |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
252 set2({0, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
253 1, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
254 2, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
255 3, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
256 4, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
257 5, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
258 6})''') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
259 self.assertEqual(pprint.pformat(set3(range(7)), width=20), |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
260 'set3({0, 1, 2, 3, 4, 5, 6})') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
261 |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
262 self.assertEqual(pprint.pformat(frozenset()), 'frozenset()') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
263 self.assertEqual(pprint.pformat(frozenset(range(3))), |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
264 'frozenset({0, 1, 2})') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
265 self.assertEqual(pprint.pformat(frozenset(range(7)), width=20), '''\ |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
266 frozenset({0, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
267 1, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
268 2, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
269 3, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
270 4, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
271 5, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
272 6})''') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
273 self.assertEqual(pprint.pformat(frozenset2(range(7)), width=20), '''\ |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
274 frozenset2({0, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
275 1, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
276 2, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
277 3, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
278 4, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
279 5, |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
280 6})''') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
281 self.assertEqual(pprint.pformat(frozenset3(range(7)), width=20), |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
282 'frozenset3({0, 1, 2, 3, 4, 5, 6})') |
|
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
283 |
|
76485
6e5855854a2e
Implement PEP 412: Key-sharing dictionaries (closes #13903)
Benjamin Peterson <benjamin@python.org>
parents:
64891
diff
changeset
|
284 @unittest.expectedFailure |
|
6e5855854a2e
Implement PEP 412: Key-sharing dictionaries (closes #13903)
Benjamin Peterson <benjamin@python.org>
parents:
64891
diff
changeset
|
285 #See http://bugs.python.org/issue13907 |
|
64891
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
286 @test.support.cpython_only |
|
85919
65943dc15afc
Issue #19137: The pprint module now correctly formats instances of set and
Serhiy Storchaka <storchaka@gmail.com>
parents:
78215
diff
changeset
|
287 def test_set_of_sets_reprs(self): |
|
64891
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
288 # This test creates a complex arrangement of frozensets and |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
289 # compares the pretty-printed repr against a string hard-coded in |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
290 # the test. The hard-coded repr depends on the sort order of |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
291 # frozensets. |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
292 # |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
293 # However, as the docs point out: "Since sets only define |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
294 # partial ordering (subset relationships), the output of the |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
295 # list.sort() method is undefined for lists of sets." |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
296 # |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
297 # In a nutshell, the test assumes frozenset({0}) will always |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
298 # sort before frozenset({1}), but: |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
299 # |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
300 # >>> frozenset({0}) < frozenset({1}) |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
301 # False |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
302 # >>> frozenset({1}) < frozenset({0}) |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
303 # False |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
304 # |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
305 # Consequently, this test is fragile and |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
306 # implementation-dependent. Small changes to Python's sort |
|
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
307 # algorithm cause the test to fail when it should pass. |
|
76485
6e5855854a2e
Implement PEP 412: Key-sharing dictionaries (closes #13903)
Benjamin Peterson <benjamin@python.org>
parents:
64891
diff
changeset
|
308 # XXX Or changes to the dictionary implmentation... |
|
64891
b3d0deaf50e5
Issue9131: Mark fragile test as CPython-specific
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
64583
diff
changeset
|
309 |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
310 cube_repr_tgt = """\ |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
311 {frozenset(): frozenset({frozenset({2}), frozenset({0}), frozenset({1})}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
312 frozenset({0}): frozenset({frozenset(), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
313 frozenset({0, 2}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
314 frozenset({0, 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
315 frozenset({1}): frozenset({frozenset(), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
316 frozenset({1, 2}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
317 frozenset({0, 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
318 frozenset({2}): frozenset({frozenset(), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
319 frozenset({1, 2}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
320 frozenset({0, 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
321 frozenset({1, 2}): frozenset({frozenset({2}), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
322 frozenset({1}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
323 frozenset({0, 1, 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
324 frozenset({0, 2}): frozenset({frozenset({2}), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
325 frozenset({0}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
326 frozenset({0, 1, 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
327 frozenset({0, 1}): frozenset({frozenset({0}), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
328 frozenset({1}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
329 frozenset({0, 1, 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
330 frozenset({0, 1, 2}): frozenset({frozenset({1, 2}), |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
331 frozenset({0, 2}), |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
332 frozenset({0, 1})})}""" |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
333 cube = test.test_set.cube(3) |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
334 self.assertEqual(pprint.pformat(cube), cube_repr_tgt) |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
335 cubo_repr_tgt = """\ |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
336 {frozenset({frozenset({0, 2}), frozenset({0})}): frozenset({frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
337 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
338 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
339 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
340 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
341 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
342 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
343 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
344 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
345 frozenset({0})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
346 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
347 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
348 2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
349 frozenset({frozenset({0, 1}), frozenset({1})}): frozenset({frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
350 1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
351 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
352 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
353 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
354 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
355 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
356 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
357 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
358 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
359 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
360 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
361 frozenset({1})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
362 frozenset({frozenset({1, 2}), frozenset({1})}): frozenset({frozenset({frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
363 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
364 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
365 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
366 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
367 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
368 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
369 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
370 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
371 frozenset({1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
372 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
373 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
374 1})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
375 frozenset({frozenset({1, 2}), frozenset({2})}): frozenset({frozenset({frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
376 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
377 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
378 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
379 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
380 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
381 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
382 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
383 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
384 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
385 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
386 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
387 frozenset({2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
388 frozenset({frozenset(), frozenset({0})}): frozenset({frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
389 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
390 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
391 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
392 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
393 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
394 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
395 frozenset({1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
396 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
397 frozenset({2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
398 frozenset({frozenset(), frozenset({1})}): frozenset({frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
399 frozenset({0})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
400 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
401 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
402 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
403 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
404 frozenset({2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
405 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
406 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
407 1})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
408 frozenset({frozenset({2}), frozenset()}): frozenset({frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
409 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
410 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
411 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
412 frozenset({0})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
413 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
414 frozenset({1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
415 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
416 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
417 2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
418 frozenset({frozenset({0, 1, 2}), frozenset({0, 1})}): frozenset({frozenset({frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
419 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
420 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
421 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
422 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
423 frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
424 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
425 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
426 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
427 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
428 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
429 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
430 1})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
431 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
432 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
433 1})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
434 frozenset({frozenset({0}), frozenset({0, 1})}): frozenset({frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
435 frozenset({0})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
436 frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
437 1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
438 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
439 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
440 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
441 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
442 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
443 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
444 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
445 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
446 1})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
447 frozenset({frozenset({2}), frozenset({0, 2})}): frozenset({frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
448 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
449 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
450 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
451 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
452 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
453 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
454 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
455 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
456 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
457 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
458 frozenset({frozenset(), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
459 frozenset({2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
460 frozenset({frozenset({0, 1, 2}), frozenset({0, 2})}): frozenset({frozenset({frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
461 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
462 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
463 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
464 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
465 frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
466 1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
467 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
468 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
469 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
470 frozenset({frozenset({0}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
471 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
472 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
473 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
474 frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
475 2})})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
476 frozenset({frozenset({1, 2}), frozenset({0, 1, 2})}): frozenset({frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
477 2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
478 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
479 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
480 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
481 frozenset({frozenset({0, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
482 1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
483 frozenset({0, |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
484 1, |
|
45067
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
485 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
486 frozenset({frozenset({2}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
487 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
488 2})}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
489 frozenset({frozenset({1}), |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
490 frozenset({1, |
|
8930ff230ee9
Update pprint() to match the new repr style for frozensets
Raymond Hettinger <python@rcn.com>
parents:
44943
diff
changeset
|
491 2})})})}""" |
|
44943
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
492 |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
493 cubo = test.test_set.linegraph(cube) |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
494 self.assertEqual(pprint.pformat(cubo), cubo_repr_tgt) |
|
6547be11f443
Merged revisions 60245-60277 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
42050
diff
changeset
|
495 |
|
47080
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
496 def test_depth(self): |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
497 nested_tuple = (1, (2, (3, (4, (5, 6))))) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
498 nested_dict = {1: {2: {3: {4: {5: {6: 6}}}}}} |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
499 nested_list = [1, [2, [3, [4, [5, [6, []]]]]]] |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
500 self.assertEqual(pprint.pformat(nested_tuple), repr(nested_tuple)) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
501 self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict)) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
502 self.assertEqual(pprint.pformat(nested_list), repr(nested_list)) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
503 |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
504 lv1_tuple = '(1, (...))' |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
505 lv1_dict = '{1: {...}}' |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
506 lv1_list = '[1, [...]]' |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
507 self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
508 self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
509 self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list) |
|
58a0d5524f9a
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
45067
diff
changeset
|
510 |
|
57340
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
511 def test_sort_unorderable_values(self): |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
512 # Issue 3976: sorted pprints fail for unorderable values. |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
513 n = 20 |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
514 keys = [Unorderable() for i in range(n)] |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
515 random.shuffle(keys) |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
516 skeys = sorted(keys, key=id) |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
517 clean = lambda s: s.replace(' ', '').replace('\n','') |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
518 |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
519 self.assertEqual(clean(pprint.pformat(set(keys))), |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
520 '{' + ','.join(map(repr, skeys)) + '}') |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
521 self.assertEqual(clean(pprint.pformat(frozenset(keys))), |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
522 'frozenset({' + ','.join(map(repr, skeys)) + '})') |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
523 self.assertEqual(clean(pprint.pformat(dict.fromkeys(keys))), |
|
b31a33c36f08
Issue 3976: fix pprint for sets, frozensets, and dicts containing unorderable types.
Raymond Hettinger <python@rcn.com>
parents:
55593
diff
changeset
|
524 '{' + ','.join('%r:None' % k for k in skeys) + '}') |
|
22766
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
525 |
|
78212
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
526 # Issue 10017: TypeError on user-defined types as dict keys. |
|
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
527 self.assertEqual(pprint.pformat({Unorderable: 0, 1: 0}), |
|
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
528 '{1: 0, ' + repr(Unorderable) +': 0}') |
|
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
529 |
|
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
530 # Issue 14998: TypeError on tuples with NoneTypes as dict keys. |
|
78214
29642f82bbcc
Fix test_pprint random dict ordering.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
78212
diff
changeset
|
531 keys = [(1,), (None,)] |
|
29642f82bbcc
Fix test_pprint random dict ordering.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
78212
diff
changeset
|
532 self.assertEqual(pprint.pformat(dict.fromkeys(keys, 0)), |
|
29642f82bbcc
Fix test_pprint random dict ordering.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
78212
diff
changeset
|
533 '{%r: 0, %r: 0}' % tuple(sorted(keys, key=id))) |
|
78212
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
534 |
|
82919
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
535 def test_str_wrap(self): |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
536 # pprint tries to wrap strings intelligently |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
537 fox = 'the quick brown fox jumped over a lazy dog' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
538 self.assertEqual(pprint.pformat(fox, width=20), """\ |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
539 'the quick brown ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
540 'fox jumped over ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
541 'a lazy dog'""") |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
542 self.assertEqual(pprint.pformat({'a': 1, 'b': fox, 'c': 2}, |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
543 width=26), """\ |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
544 {'a': 1, |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
545 'b': 'the quick brown ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
546 'fox jumped over ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
547 'a lazy dog', |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
548 'c': 2}""") |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
549 # With some special characters |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
550 # - \n always triggers a new line in the pprint |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
551 # - \t and \n are escaped |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
552 # - non-ASCII is allowed |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
553 # - an apostrophe doesn't disrupt the pprint |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
554 special = "Portons dix bons \"whiskys\"\nà l'avocat goujat\t qui fumait au zoo" |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
555 self.assertEqual(pprint.pformat(special, width=20), """\ |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
556 'Portons dix bons ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
557 '"whiskys"\\n' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
558 "à l'avocat " |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
559 'goujat\\t qui ' |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
560 'fumait au zoo'""") |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
561 # An unwrappable string is formatted as its repr |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
562 unwrappable = "x" * 100 |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
563 self.assertEqual(pprint.pformat(unwrappable, width=80), repr(unwrappable)) |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
564 self.assertEqual(pprint.pformat(''), "''") |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
565 # Check that the pprint is a usable repr |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
566 special *= 10 |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
567 for width in range(3, 40): |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
568 formatted = pprint.pformat(special, width=width) |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
569 self.assertEqual(eval("(" + formatted + ")"), special) |
|
5a2296093645
Issue #17150: pprint now uses line continuations to wrap long string literals.
Antoine Pitrou <solipsis@pitrou.net>
parents:
78215
diff
changeset
|
570 |
|
85921
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
571 def test_compact(self): |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
572 o = ([list(range(i * i)) for i in range(5)] + |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
573 [list(range(i)) for i in range(6)]) |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
574 expected = """\ |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
575 [[], [0], [0, 1, 2, 3], |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
576 [0, 1, 2, 3, 4, 5, 6, 7, 8], |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
577 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
578 14, 15], |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
579 [], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
580 [0, 1, 2, 3, 4]]""" |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
581 self.assertEqual(pprint.pformat(o, width=48, compact=True), expected) |
|
ae0306c8f7a3
Issue #19132: The pprint module now supports compact mode.
Serhiy Storchaka <storchaka@gmail.com>
parents:
85920
diff
changeset
|
582 |
|
78212
03cda5360dc6
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
64891
diff
changeset
|
583 |
|
22766
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
584 class DottedPrettyPrinter(pprint.PrettyPrinter): |
|
24957
dc66eb4cd17a
Standardize behavior: no docstrings in test functions.
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
585 |
|
22766
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
586 def format(self, object, context, maxlevels, level): |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
587 if isinstance(object, str): |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
588 if ' ' in object: |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
31085
diff
changeset
|
589 return repr(object), 1, 0 |
|
22766
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
590 else: |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
591 return object, 0, 0 |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
592 else: |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
593 return pprint.PrettyPrinter.format( |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
594 self, object, context, maxlevels, level) |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
595 |
|
d26d8575ac62
Add an experimental mechanism to support extending the pprint formatting.
Fred Drake <fdrake@acm.org>
parents:
21061
diff
changeset
|
596 |
|
20013
e3184e46303b
Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
597 def test_main(): |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
47080
diff
changeset
|
598 test.support.run_unittest(QueryTestCase) |
|
20013
e3184e46303b
Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
599 |
|
e3184e46303b
Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
600 |
|
e3184e46303b
Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
601 if __name__ == "__main__": |
|
e3184e46303b
Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
602 test_main() |
