[Python-checkins] r84961 - python/branches/py3k/Lib/test/test_pprint.py

daniel.stutzbach python-checkins at python.org
Tue Sep 21 23:08:09 CEST 2010


Author: daniel.stutzbach
Date: Tue Sep 21 23:08:09 2010
New Revision: 84961

Log:
Issue9131: Mark fragile test as CPython-specific

Modified:
   python/branches/py3k/Lib/test/test_pprint.py

Modified: python/branches/py3k/Lib/test/test_pprint.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pprint.py	(original)
+++ python/branches/py3k/Lib/test/test_pprint.py	Tue Sep 21 23:08:09 2010
@@ -219,7 +219,29 @@
  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()')


More information about the Python-checkins mailing list