@@ -778,12 +778,16 @@ def test_dataclasses(self, testdir):
778
778
result .assert_outcomes (failed = 1 , passed = 0 )
779
779
result .stdout .fnmatch_lines (
780
780
[
781
- "*Omitting 1 identical items, use -vv to show*" ,
782
- "*Differing attributes:*" ,
783
- "*field_b: 'b' != 'c'*" ,
784
- "*- c*" ,
785
- "*+ b*" ,
786
- ]
781
+ "E Omitting 1 identical items, use -vv to show" ,
782
+ "E Differing attributes:" ,
783
+ "E ['field_b']" ,
784
+ "E " ,
785
+ "E Drill down into differing attribute field_b:" ,
786
+ "E field_b: 'b' != 'c'..." ,
787
+ "E " ,
788
+ "E ...Full output truncated (3 lines hidden), use '-vv' to show" ,
789
+ ],
790
+ consecutive = True ,
787
791
)
788
792
789
793
@pytest .mark .skipif (sys .version_info < (3 , 7 ), reason = "Dataclasses in Python3.7+" )
@@ -793,14 +797,16 @@ def test_recursive_dataclasses(self, testdir):
793
797
result .assert_outcomes (failed = 1 , passed = 0 )
794
798
result .stdout .fnmatch_lines (
795
799
[
796
- "*Omitting 1 identical items, use -vv to show*" ,
797
- "*Differing attributes:*" ,
798
- "*field_b: ComplexDataObject2(*SimpleDataObject(field_a=2, field_b='c')) != ComplexDataObject2(*SimpleDataObject(field_a=3, field_b='c'))*" , # noqa
799
- "*Drill down into differing attribute field_b:*" ,
800
- "*Omitting 1 identical items, use -vv to show*" ,
801
- "*Differing attributes:*" ,
802
- "*Full output truncated*" ,
803
- ]
800
+ "E Omitting 1 identical items, use -vv to show" ,
801
+ "E Differing attributes:" ,
802
+ "E ['g', 'h', 'j']" ,
803
+ "E " ,
804
+ "E Drill down into differing attribute g:" ,
805
+ "E g: S(a=10, b='ten') != S(a=20, b='xxx')..." ,
806
+ "E " ,
807
+ "E ...Full output truncated (52 lines hidden), use '-vv' to show" ,
808
+ ],
809
+ consecutive = True ,
804
810
)
805
811
806
812
@pytest .mark .skipif (sys .version_info < (3 , 7 ), reason = "Dataclasses in Python3.7+" )
@@ -810,19 +816,30 @@ def test_recursive_dataclasses_verbose(self, testdir):
810
816
result .assert_outcomes (failed = 1 , passed = 0 )
811
817
result .stdout .fnmatch_lines (
812
818
[
813
- "*Matching attributes:*" ,
814
- "*['field_a']*" ,
815
- "*Differing attributes:*" ,
816
- "*field_b: ComplexDataObject2(*SimpleDataObject(field_a=2, field_b='c')) != ComplexDataObject2(*SimpleDataObject(field_a=3, field_b='c'))*" , # noqa
817
- "*Matching attributes:*" ,
818
- "*['field_a']*" ,
819
- "*Differing attributes:*" ,
820
- "*field_b: SimpleDataObject(field_a=2, field_b='c') != SimpleDataObject(field_a=3, field_b='c')*" , # noqa
821
- "*Matching attributes:*" ,
822
- "*['field_b']*" ,
823
- "*Differing attributes:*" ,
824
- "*field_a: 2 != 3" ,
825
- ]
819
+ "E Matching attributes:" ,
820
+ "E ['i']" ,
821
+ "E Differing attributes:" ,
822
+ "E ['g', 'h', 'j']" ,
823
+ "E " ,
824
+ "E Drill down into differing attribute g:" ,
825
+ "E g: S(a=10, b='ten') != S(a=20, b='xxx')" ,
826
+ "E " ,
827
+ "E Differing attributes:" ,
828
+ "E ['a', 'b']" ,
829
+ "E " ,
830
+ "E Drill down into differing attribute a:" ,
831
+ "E a: 10 != 20" ,
832
+ "E +10" ,
833
+ "E -20" ,
834
+ "E " ,
835
+ "E Drill down into differing attribute b:" ,
836
+ "E b: 'ten' != 'xxx'" ,
837
+ "E - xxx" ,
838
+ "E + ten" ,
839
+ "E " ,
840
+ "E Drill down into differing attribute h:" ,
841
+ ],
842
+ consecutive = True ,
826
843
)
827
844
828
845
@pytest .mark .skipif (sys .version_info < (3 , 7 ), reason = "Dataclasses in Python3.7+" )
@@ -868,9 +885,9 @@ class SimpleDataObject:
868
885
869
886
lines = callequal (left , right )
870
887
assert lines is not None
871
- assert lines [1 ].startswith ("Omitting 1 identical item" )
888
+ assert lines [2 ].startswith ("Omitting 1 identical item" )
872
889
assert "Matching attributes" not in lines
873
- for line in lines [1 :]:
890
+ for line in lines [2 :]:
874
891
assert "field_a" not in line
875
892
876
893
def test_attrs_recursive (self ) -> None :
@@ -910,7 +927,8 @@ class SimpleDataObject:
910
927
911
928
lines = callequal (left , right )
912
929
assert lines is not None
913
- assert "field_d: 'a' != 'b'" in lines
930
+ # indentation in output because of nested object structure
931
+ assert " field_d: 'a' != 'b'" in lines
914
932
915
933
def test_attrs_verbose (self ) -> None :
916
934
@attr .s
@@ -923,9 +941,9 @@ class SimpleDataObject:
923
941
924
942
lines = callequal (left , right , verbose = 2 )
925
943
assert lines is not None
926
- assert lines [1 ].startswith ("Matching attributes:" )
927
- assert "Omitting" not in lines [1 ]
928
- assert lines [2 ] == "['field_a']"
944
+ assert lines [2 ].startswith ("Matching attributes:" )
945
+ assert "Omitting" not in lines [2 ]
946
+ assert lines [3 ] == "['field_a']"
929
947
930
948
def test_attrs_with_attribute_comparison_off (self ):
931
949
@attr .s
@@ -937,11 +955,12 @@ class SimpleDataObject:
937
955
right = SimpleDataObject (1 , "b" )
938
956
939
957
lines = callequal (left , right , verbose = 2 )
958
+ print (lines )
940
959
assert lines is not None
941
- assert lines [1 ].startswith ("Matching attributes:" )
960
+ assert lines [2 ].startswith ("Matching attributes:" )
942
961
assert "Omitting" not in lines [1 ]
943
- assert lines [2 ] == "['field_a']"
944
- for line in lines [2 :]:
962
+ assert lines [3 ] == "['field_a']"
963
+ for line in lines [3 :]:
945
964
assert "field_b" not in line
946
965
947
966
def test_comparing_two_different_attrs_classes (self ):
0 commit comments