Repository navigation
gh-111147: Fix test_set_of_sets_reprs in test_pprint - #111148
Conversation
|
I suppose that @serhiy-storchaka would be a better candidate than me to review this change. |
|
I replaces tests with tests with deterministic result (when all sets can be strictly ordered). I do not know what to do with testing non-orderable sets, which perhaps was the purpose of the original set. Maybe we should test the actual result against multiple expected results. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I dislike skipped tests. IMO these tests are better than having tests expected to fail.
|
@serhiy-storchaka: Are you ok with this change? Does it make test_pprint better?
Maybe add a test with a set of 2 strings and check if the repr() is in one of the two possible outputs? |
|
I thought that @rhettinger should make the decision, but he removed himself. Well, I propose the following plan:
|
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Actually, in the multiline case, the elements of the innermost frozensets are always sorted. So you can get
frozenset((
"qwerty is also absurdly long",
"xyz very-very long string",
)),
but not
frozenset((
"xyz very-very long string",
"qwerty is also absurdly long",
)),
It will reduce the number of cases by 4 times.
On other hand, in the single-line variant the result is the same as the repr. So pprint.pformat(...) == repr(...) if it fits in a single line.
There is an interesting middle case. When the result is multiline, but inner frozensets fit in a single line. Then there are just two variants, differentiated by the order of elements of the outer frozenset.
"""
frozenset({%r,
%r})
""" % (f1, f2)
and
"""
frozenset({%r,
%r})
""" % (f2, f1)
I've tried locally with these cases removed and
However, it does not work the same way as fully multiline case. For example, this result is expected: Traceback: |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
🤖 New build scheduled with the buildbot fleet by @serhiy-storchaka for commit 6f8ca31 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
…nGH-111148) Make it stable and not depending on implementation details.
…nGH-111148) Make it stable and not depending on implementation details.
I left
@cpython_onlyfor no real reason, I think that others should behave the same way.But, it feels like a lower risk to me.
test_set_of_sets_reprsoftest_pprintis silently ignored #111147