Skip to content

Commit bcc2e77

Browse files
Apply suggestions from code review
Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 57010a7 commit bcc2e77

File tree

1 file changed

+13
-57
lines changed

1 file changed

+13
-57
lines changed

Lib/test/test_pprint.py

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -665,73 +665,29 @@ def test_set_of_sets_reprs(self):
665665
self.assertEqual(pprint.pformat(data), repr(data))
666666

667667
# Single-line, unordered:
668-
self.assertIn(
669-
pprint.pformat(
670-
frozenset((
671-
frozenset(("xyz", "qwerty")),
672-
frozenset(("abcd", "spam"))),
673-
),
674-
),
675-
[
676-
"frozenset({frozenset({'qwerty', 'xyz'}), frozenset({'spam', 'abcd'})})",
677-
"frozenset({frozenset({'xyz', 'qwerty'}), frozenset({'spam', 'abcd'})})",
678-
"frozenset({frozenset({'qwerty', 'xyz'}), frozenset({'abcd', 'spam'})})",
679-
"frozenset({frozenset({'xyz', 'qwerty'}), frozenset({'abcd', 'spam'})})",
680-
681-
"frozenset({frozenset({'spam', 'abcd'}), frozenset({'qwerty', 'xyz'})})",
682-
"frozenset({frozenset({'spam', 'abcd'}), frozenset({'xyz', 'qwerty'})})",
683-
"frozenset({frozenset({'abcd', 'spam'}), frozenset({'qwerty', 'xyz'})})",
684-
"frozenset({frozenset({'abcd', 'spam'}), frozenset({'xyz', 'qwerty'})})",
685-
686-
],
687-
)
668+
fs1 = frozenset(("xyz", "qwerty"))
669+
fs2 = frozenset(("abcd", "spam"))
670+
fs = frozenset((fs1, fs2)))
671+
self.assertEqual(pprint.pformat(fs, repr(fs))
688672

689673
# Multiline, unordered:
690674
def check(res, invariants):
691675
self.assertIn(res, [textwrap.dedent(i).strip() for i in invariants])
692676

693677
# Inner-most frozensets are singleline, result is multiline, unordered:
678+
fs1 = frozenset(('regular string', 'other string'))
679+
fs2 = frozenset(('third string', 'one more string'))
694680
check(
695-
pprint.pformat(
696-
frozenset((
697-
frozenset(('regular string', 'other string')),
698-
frozenset(('third string', 'one more string')),
699-
))
700-
),
681+
pprint.pformat(frozenset((fs1, fs2))),
701682
[
702683
"""
703-
frozenset({frozenset({'regular string', 'other string'}),
704-
frozenset({'third string', 'one more string'})})
705-
""",
706-
"""
707-
frozenset({frozenset({'regular string', 'other string'}),
708-
frozenset({'one more string', 'third string'})})
709-
""",
710-
"""
711-
frozenset({frozenset({'other string', 'regular string'}),
712-
frozenset({'third string', 'one more string'})})
713-
""",
714-
"""
715-
frozenset({frozenset({'other string', 'regular string'}),
716-
frozenset({'one more string', 'third string'})})
717-
""",
718-
# -
719-
"""
720-
frozenset({frozenset({'third string', 'one more string'}),
721-
frozenset({'regular string', 'other string'})})
722-
""",
723-
"""
724-
frozenset({frozenset({'third string', 'one more string'}),
725-
frozenset({'other string', 'regular string'})})
726-
""",
727-
"""
728-
frozenset({frozenset({'one more string', 'third string'}),
729-
frozenset({'regular string', 'other string'})})
730-
""",
684+
frozenset({%r,
685+
%r})
686+
""" % (fs1, fs2),
731687
"""
732-
frozenset({frozenset({'one more string', 'third string'}),
733-
frozenset({'other string', 'regular string'})})
734-
""",
688+
frozenset({%r,
689+
%r})
690+
""" % (fs2, fs1),
735691
],
736692
)
737693

0 commit comments

Comments
 (0)