You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2010-09-21.21:09:08.524>created_at=<Date2010-06-30.19:47:59.096>labels= ['type-bug', 'tests']
title='test_set_reprs in test_pprint is fragile'updated_at=<Date2010-09-21.21:09:08.522>user='https://bugs.python.org/stutzbach'
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.
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.
Activity
stutzbach commentedon Jun 30, 2010
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:
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.
mdickinson commentedon Jun 30, 2010
I agree that this looks a bit suspicious.
Adding Raymond to the nosy list, since it looks like this is his code (r60264).
rhettinger commentedon Jun 30, 2010
Yes, it's a fragile and crummy test.
Feel free to delete it.
rhettinger commentedon Jun 30, 2010
After discussion on #python-dev, have decided to mark the test as implementation specific and add a comment about why the test is fragile.
stutzbach commentedon Aug 20, 2010
How do we mark a test as implementation specific? Is there a decorator for that?
stutzbach commentedon Aug 21, 2010
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.
stutzbach commentedon Aug 21, 2010
errr... ignore that first patch (now deleted)
:-)
stutzbach commentedon Sep 21, 2010
Committed in r84961