]> granicus.if.org Git - python/commitdiff
Issue9131: Mark fragile test as CPython-specific
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>
Tue, 21 Sep 2010 21:08:09 +0000 (21:08 +0000)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>
Tue, 21 Sep 2010 21:08:09 +0000 (21:08 +0000)
Lib/test/test_pprint.py

index 1a38ece60b074fbee0447010279f6bc64a341527..4e53cd8a015e5c78ad8306137668457ccf9e7cf3 100644 (file)
@@ -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()')