This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_set_reprs in test_pprint is fragile
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: stutzbach Nosy List: mark.dickinson, rhettinger, stutzbach
Priority: low Keywords: needs review, patch

Created on 2010-06-30 19:47 by stutzbach, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue9131.patch stutzbach, 2010-08-21 02:34
Messages (8)
msg109008 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-06-30 19:47
test_set_reprs in test_pprint creates a complex arrangement of frozensets and tests the pretty-printed repr against a string hard-coded in the test.  The hard-coded repr depends on the sort order of frozensets.  

However, "Since sets only define partial ordering (subset relationships), the output of the list.sort() method is undefined for lists of sets." (quoting http://docs.python.org/release/3.1/library/stdtypes.html#set-types-set-frozenset)

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.  Small changes to Python's sort algorithm cause the test to fail when it should pass.

I ran into this while playing with optimizations to the sort function, but I imagine other Python implementations will also run into trouble with this test.
msg109016 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-06-30 20:26
I agree that this looks a bit suspicious.

Adding Raymond to the nosy list, since it looks like this is his code (r60264).
msg109018 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-06-30 20:57
Yes, it's a fragile and crummy test.
Feel free to delete it.
msg109020 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-06-30 21:32
After discussion on #python-dev, have decided to mark the test as implementation specific and add a comment about why the test is fragile.
msg114451 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-08-20 20:36
How do we mark a test as implementation specific?  Is there a decorator for that?
msg114473 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-08-21 02:24
Nevermind, I found it: @support.cpython_only

I'll work on a patch to add the decorator and a comment about why the test is fragile.
msg114474 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-08-21 02:33
errr... ignore that first patch (now deleted)

:-)
msg117100 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2010-09-21 21:09
Committed in r84961
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53377
2010-09-21 21:09:08stutzbachsetstatus: open -> closed
versions: - Python 3.3
messages: + msg117100

type: behavior
stage: patch review -> resolved
2010-08-22 08:04:27rhettingersetassignee: rhettinger -> stutzbach
2010-08-21 02:34:16stutzbachsetfiles: + issue9131.patch
2010-08-21 02:34:00stutzbachsetfiles: - issue9131.patch
2010-08-21 02:33:19stutzbachsetfiles: + issue9131.patch

messages: + msg114474
2010-08-21 02:32:24stutzbachsetfiles: - issue9131.patch
2010-08-21 02:29:54stutzbachsetkeywords: + patch, needs review
files: + issue9131.patch
resolution: accepted
stage: needs patch -> patch review
2010-08-21 02:24:53stutzbachsetmessages: + msg114473
2010-08-20 20:36:48stutzbachsetmessages: + msg114451
2010-06-30 21:32:33rhettingersetassignee: stutzbach -> rhettinger
messages: + msg109020
2010-06-30 20:57:58rhettingersetmessages: + msg109018
2010-06-30 20:26:51mark.dickinsonsetnosy: + rhettinger, mark.dickinson
messages: + msg109016
2010-06-30 19:47:59stutzbachcreate