summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pprint.py
diff options
context:
space:
mode:
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-21 21:08:09 (GMT)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-21 21:08:09 (GMT)
commitc944cfc793db056d59084cca03297c5b1ad0e487 (patch)
tree92be6f057d8b4e43e78be6d2f8435382ef8327c9 /Lib/test/test_pprint.py
parent2f816e6a10d7a56a2e277d7f5b1b25aec5e6a71d (diff)
downloadcpython-c944cfc793db056d59084cca03297c5b1ad0e487.zip
cpython-c944cfc793db056d59084cca03297c5b1ad0e487.tar.gz
cpython-c944cfc793db056d59084cca03297c5b1ad0e487.tar.bz2
Issue9131: Mark fragile test as CPython-specific
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r--Lib/test/test_pprint.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 1a38ece..4e53cd8 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -219,7 +219,29 @@ class QueryTestCase(unittest.TestCase):
others.should.not.be: like.this}"""
self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
+ @test.support.cpython_only
def test_set_reprs(self):
+ # This test creates a complex arrangement of frozensets and
+ # compares the pretty-printed repr against a string hard-coded in
+ # the test. The hard-coded repr depends on the sort order of
+ # frozensets.
+ #
+ # However, as the docs point out: "Since sets only define
+ # partial ordering (subset relationships), the output of the
+ # list.sort() method is undefined for lists of sets."
+ #
+ # In a nutshell, the test assumes frozenset({0}) will always
+ # sort before frozenset({1}), but:
+ #
+ # >>> frozenset({0}) < frozenset({1})
+ # False
+ # >>> frozenset({1}) < frozenset({0})
+ # False
+ #
+ # Consequently, this test is fragile and
+ # implementation-dependent. Small changes to Python's sort
+ # algorithm cause the test to fail when it should pass.
+
self.assertEqual(pprint.pformat(set()), 'set()')
self.assertEqual(pprint.pformat(set(range(3))), '{0, 1, 2}')
self.assertEqual(pprint.pformat(frozenset()), 'frozenset()')