@@ -648,16 +648,21 @@ def test_set_of_sets_reprs(self):
648
648
import textwrap
649
649
650
650
# Single-line, always ordered:
651
+ data = frozenset ((frozenset (), frozenset ((1 , 2 , 3 ))))
651
652
self .assertEqual (
652
- pprint .pformat (frozenset (( frozenset (), frozenset (( 1 , 2 , 3 )))) ),
653
+ pprint .pformat (data ),
653
654
'frozenset({frozenset(), frozenset({1, 2, 3})})' ,
654
655
)
656
+ self .assertEqual (pprint .pformat (data ), repr (data ))
657
+
658
+ data = {
659
+ frozenset ((1 , 2 )): frozenset ((frozenset (), frozenset ((1 , 2 , 3 )))),
660
+ }
655
661
self .assertEqual (
656
- pprint .pformat ({
657
- frozenset ((1 , 2 )): frozenset ((frozenset (), frozenset ((1 , 2 , 3 )))),
658
- }),
662
+ pprint .pformat (data ),
659
663
'{frozenset({1, 2}): frozenset({frozenset(), frozenset({1, 2, 3})})}' ,
660
664
)
665
+ self .assertEqual (pprint .pformat (data ), repr (data ))
661
666
662
667
# Single-line, unordered:
663
668
self .assertIn (
@@ -677,13 +682,60 @@ def test_set_of_sets_reprs(self):
677
682
"frozenset({frozenset({'spam', 'abcd'}), frozenset({'xyz', 'qwerty'})})" ,
678
683
"frozenset({frozenset({'abcd', 'spam'}), frozenset({'qwerty', 'xyz'})})" ,
679
684
"frozenset({frozenset({'abcd', 'spam'}), frozenset({'xyz', 'qwerty'})})" ,
685
+
680
686
],
681
687
)
682
688
683
689
# Multiline, unordered:
684
690
def check (res , invariants ):
685
691
self .assertIn (res , [textwrap .dedent (i ).strip () for i in invariants ])
686
692
693
+ # Inner-most frozensets are singleline, result is multiline, unordered:
694
+ check (
695
+ pprint .pformat (
696
+ frozenset ((
697
+ frozenset (('regular string' , 'other string' )),
698
+ frozenset (('third string' , 'one more string' )),
699
+ ))
700
+ ),
701
+ [
702
+ """
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
+ """ ,
731
+ """
732
+ frozenset({frozenset({'one more string', 'third string'}),
733
+ frozenset({'other string', 'regular string'})})
734
+ """ ,
735
+ ],
736
+ )
737
+
738
+ # Everything is multiline, unordered:
687
739
check (
688
740
pprint .pformat (
689
741
frozenset ((
@@ -712,22 +764,6 @@ def check(res, invariants):
712
764
'qwerty is also absurdly long'})})
713
765
""" ,
714
766
715
- """
716
- frozenset({frozenset({'spam is not so long',
717
- 'abcd is even longer that before'}),
718
- frozenset({'qwerty is also absurdly long',
719
- 'xyz very-very long string'})})
720
- """ ,
721
-
722
- """
723
- frozenset({frozenset({'spam is not so long',
724
- 'abcd is even longer that before'}),
725
- frozenset({'xyz very-very long string',
726
- 'qwerty is also absurdly long'})})
727
- """ ,
728
-
729
- # -
730
-
731
767
"""
732
768
frozenset({frozenset({'qwerty is also absurdly long',
733
769
'xyz very-very long string'}),
@@ -741,20 +777,6 @@ def check(res, invariants):
741
777
frozenset({'spam is not so long',
742
778
'abcd is even longer that before'})})
743
779
""" ,
744
-
745
- """
746
- frozenset({frozenset({'xyz very-very long string',
747
- 'qwerty is also absurdly long'}),
748
- frozenset({'abcd is even longer that before',
749
- 'spam is not so long'})})
750
- """ ,
751
-
752
- """
753
- frozenset({frozenset({'xyz very-very long string',
754
- 'qwerty is also absurdly long'}),
755
- frozenset({'spam is not so long',
756
- 'abcd is even longer that before'})})
757
- """ ,
758
780
],
759
781
)
760
782
0 commit comments