@@ -77,6 +77,9 @@ def test_quote_type_any(self):
77
77
' word 1\n ' # fails
78
78
' word 2\n '
79
79
'multiline string 4:\n '
80
+ ' "word 1\n '
81
+ ' word 2"\n '
82
+ 'multiline string 5:\n '
80
83
' "word 1\\ \n '
81
84
' word 2"\n ' ,
82
85
conf , problem1 = (9 , 3 ))
@@ -127,9 +130,12 @@ def test_quote_type_single(self):
127
130
' word 1\n ' # fails
128
131
' word 2\n '
129
132
'multiline string 4:\n '
130
- ' "word 1\\ \n '
133
+ ' "word 1\n ' # fails
134
+ ' word 2"\n '
135
+ 'multiline string 5:\n '
136
+ ' "word 1\\ \n ' # fails
131
137
' word 2"\n ' ,
132
- conf , problem1 = (9 , 3 ), problem2 = (12 , 3 ))
138
+ conf , problem1 = (9 , 3 ), problem2 = (12 , 3 ), problem3 = ( 15 , 3 ) )
133
139
134
140
def test_quote_type_double (self ):
135
141
conf = 'quoted-strings: {quote-type: double}\n '
@@ -173,6 +179,9 @@ def test_quote_type_double(self):
173
179
' word 1\n ' # fails
174
180
' word 2\n '
175
181
'multiline string 4:\n '
182
+ ' "word 1\n '
183
+ ' word 2"\n '
184
+ 'multiline string 5:\n '
176
185
' "word 1\\ \n '
177
186
' word 2"\n ' ,
178
187
conf , problem1 = (9 , 3 ))
@@ -216,6 +225,9 @@ def test_any_quotes_not_required(self):
216
225
' word 1\n '
217
226
' word 2\n '
218
227
'multiline string 4:\n '
228
+ ' "word 1\n '
229
+ ' word 2"\n '
230
+ 'multiline string 5:\n '
219
231
' "word 1\\ \n '
220
232
' word 2"\n ' ,
221
233
conf )
@@ -263,9 +275,12 @@ def test_single_quotes_not_required(self):
263
275
' word 1\n '
264
276
' word 2\n '
265
277
'multiline string 4:\n '
278
+ ' "word 1\n ' # fails
279
+ ' word 2"\n '
280
+ 'multiline string 5:\n '
266
281
' "word 1\\ \n ' # fails
267
282
' word 2"\n ' ,
268
- conf , problem1 = (12 , 3 ))
283
+ conf , problem1 = (12 , 3 ), problem2 = ( 15 , 3 ) )
269
284
270
285
def test_only_when_needed (self ):
271
286
conf = 'quoted-strings: {required: only-when-needed}\n '
@@ -307,7 +322,10 @@ def test_only_when_needed(self):
307
322
' word 1\n '
308
323
' word 2\n '
309
324
'multiline string 4:\n '
310
- ' "word 1\\ \n ' # fails
325
+ ' "word 1\n ' # fails
326
+ ' word 2"\n '
327
+ 'multiline string 5:\n '
328
+ ' "word 1\\ \n '
311
329
' word 2"\n ' ,
312
330
conf , problem1 = (12 , 3 ))
313
331
@@ -354,9 +372,12 @@ def test_only_when_needed_single_quotes(self):
354
372
' word 1\n '
355
373
' word 2\n '
356
374
'multiline string 4:\n '
375
+ ' "word 1\n '
376
+ ' word 2"\n '
377
+ 'multiline string 5:\n '
357
378
' "word 1\\ \n ' # fails
358
379
' word 2"\n ' ,
359
- conf , problem1 = (12 , 3 ))
380
+ conf , problem1 = (12 , 3 ), problem2 = ( 15 , 3 ) )
360
381
361
382
def test_only_when_needed_corner_cases (self ):
362
383
conf = 'quoted-strings: {required: only-when-needed}\n '
@@ -626,7 +647,8 @@ class QuotedKeysTestCase(RuleTestCase):
626
647
rule_id = 'quoted-strings'
627
648
628
649
def test_disabled (self ):
629
- conf_disabled = "quoted-strings: {}"
650
+ conf_disabled = ('quoted-strings: {}\n '
651
+ 'key-duplicates: disable\n ' )
630
652
key_strings = ('---\n '
631
653
'true: 2\n '
632
654
'123: 3\n '
@@ -665,6 +687,10 @@ def test_disabled(self):
665
687
' line 2\n '
666
688
': 35\n '
667
689
'?\n '
690
+ ' "line 1\n '
691
+ ' line 2"\n '
692
+ ': 37\n '
693
+ '?\n '
668
694
' "line 1\\ \n '
669
695
' line 2"\n '
670
696
': 39\n ' )
@@ -673,7 +699,8 @@ def test_disabled(self):
673
699
def test_default (self ):
674
700
# Default configuration, but with check-keys
675
701
conf_default = ("quoted-strings:\n "
676
- " check-keys: true\n " )
702
+ " check-keys: true\n "
703
+ "key-duplicates: disable\n " )
677
704
key_strings = ('---\n '
678
705
'true: 2\n '
679
706
'123: 3\n '
@@ -712,6 +739,10 @@ def test_default(self):
712
739
' line 2\n '
713
740
': 35\n '
714
741
'?\n '
742
+ ' "line 1\n '
743
+ ' line 2"\n '
744
+ ': 37\n '
745
+ '?\n '
715
746
' "line 1\\ \n '
716
747
' line 2"\n '
717
748
': 39\n ' )
@@ -721,7 +752,8 @@ def test_default(self):
721
752
def test_quote_type_any (self ):
722
753
conf = ('quoted-strings:\n '
723
754
' check-keys: true\n '
724
- ' quote-type: any\n ' )
755
+ ' quote-type: any\n '
756
+ 'key-duplicates: disable\n ' )
725
757
726
758
key_strings = ('---\n '
727
759
'true: 2\n '
@@ -761,6 +793,10 @@ def test_quote_type_any(self):
761
793
' line 2\n '
762
794
': 35\n '
763
795
'?\n '
796
+ ' "line 1\n '
797
+ ' line 2"\n '
798
+ ': 37\n '
799
+ '?\n '
764
800
' "line 1\\ \n '
765
801
' line 2"\n '
766
802
': 39\n ' )
@@ -771,7 +807,8 @@ def test_quote_type_any(self):
771
807
def test_quote_type_single (self ):
772
808
conf = ('quoted-strings:\n '
773
809
' check-keys: true\n '
774
- ' quote-type: single\n ' )
810
+ ' quote-type: single\n '
811
+ 'key-duplicates: disable\n ' )
775
812
776
813
key_strings = ('---\n '
777
814
'true: 2\n '
@@ -811,19 +848,24 @@ def test_quote_type_single(self):
811
848
' line 2\n '
812
849
': 35\n '
813
850
'?\n '
851
+ ' "line 1\n '
852
+ ' line 2"\n '
853
+ ': 37\n '
854
+ '?\n '
814
855
' "line 1\\ \n '
815
856
' line 2"\n '
816
857
': 39\n ' )
817
858
self .check (key_strings , conf ,
818
859
problem1 = (4 , 1 ), problem2 = (5 , 1 ), problem3 = (6 , 1 ),
819
860
problem4 = (7 , 1 ), problem5 = (20 , 3 ), problem6 = (21 , 3 ),
820
861
problem7 = (23 , 2 ), problem8 = (23 , 10 ), problem9 = (33 , 3 ),
821
- problem10 = (37 , 3 ))
862
+ problem10 = (37 , 3 ), problem11 = ( 41 , 3 ) )
822
863
823
864
def test_quote_type_double (self ):
824
865
conf = ('quoted-strings:\n '
825
866
' check-keys: true\n '
826
- ' quote-type: double\n ' )
867
+ ' quote-type: double\n '
868
+ 'key-duplicates: disable\n ' )
827
869
828
870
key_strings = ('---\n '
829
871
'true: 2\n '
@@ -863,6 +905,10 @@ def test_quote_type_double(self):
863
905
' line 2\n '
864
906
': 35\n '
865
907
'?\n '
908
+ ' "line 1\n '
909
+ ' line 2"\n '
910
+ ': 37\n '
911
+ '?\n '
866
912
' "line 1\\ \n '
867
913
' line 2"\n '
868
914
': 39\n ' )
@@ -874,7 +920,8 @@ def test_any_quotes_not_required(self):
874
920
conf = ('quoted-strings:\n '
875
921
' check-keys: true\n '
876
922
' quote-type: any\n '
877
- ' required: false\n ' )
923
+ ' required: false\n '
924
+ 'key-duplicates: disable\n ' )
878
925
879
926
key_strings = ('---\n '
880
927
'true: 2\n '
@@ -914,6 +961,10 @@ def test_any_quotes_not_required(self):
914
961
' line 2\n '
915
962
': 35\n '
916
963
'?\n '
964
+ ' "line 1\n '
965
+ ' line 2"\n '
966
+ ': 37\n '
967
+ '?\n '
917
968
' "line 1\\ \n '
918
969
' line 2"\n '
919
970
': 39\n ' )
@@ -923,7 +974,8 @@ def test_single_quotes_not_required(self):
923
974
conf = ('quoted-strings:\n '
924
975
' check-keys: true\n '
925
976
' quote-type: single\n '
926
- ' required: false\n ' )
977
+ ' required: false\n '
978
+ 'key-duplicates: disable\n ' )
927
979
928
980
key_strings = ('---\n '
929
981
'true: 2\n '
@@ -963,17 +1015,23 @@ def test_single_quotes_not_required(self):
963
1015
' line 2\n '
964
1016
': 35\n '
965
1017
'?\n '
1018
+ ' "line 1\n '
1019
+ ' line 2"\n '
1020
+ ': 37\n '
1021
+ '?\n '
966
1022
' "line 1\\ \n '
967
1023
' line 2"\n '
968
1024
': 39\n ' )
969
1025
self .check (key_strings , conf ,
970
1026
problem1 = (5 , 1 ), problem2 = (6 , 1 ), problem3 = (7 , 1 ),
971
- problem4 = (21 , 3 ), problem5 = (23 , 10 ), problem6 = (37 , 3 ))
1027
+ problem4 = (21 , 3 ), problem5 = (23 , 10 ), problem6 = (37 , 3 ),
1028
+ problem7 = (41 , 3 ))
972
1029
973
1030
def test_only_when_needed (self ):
974
1031
conf = ('quoted-strings:\n '
975
1032
' check-keys: true\n '
976
- ' required: only-when-needed\n ' )
1033
+ ' required: only-when-needed\n '
1034
+ 'key-duplicates: disable\n ' )
977
1035
978
1036
key_strings = ('---\n '
979
1037
'true: 2\n '
@@ -1013,6 +1071,10 @@ def test_only_when_needed(self):
1013
1071
' line 2\n '
1014
1072
': 35\n '
1015
1073
'?\n '
1074
+ ' "line 1\n '
1075
+ ' line 2"\n '
1076
+ ': 37\n '
1077
+ '?\n '
1016
1078
' "line 1\\ \n '
1017
1079
' line 2"\n '
1018
1080
': 39\n ' )
@@ -1024,7 +1086,8 @@ def test_only_when_needed_single_quotes(self):
1024
1086
conf = ('quoted-strings:\n '
1025
1087
' check-keys: true\n '
1026
1088
' quote-type: single\n '
1027
- ' required: only-when-needed\n ' )
1089
+ ' required: only-when-needed\n '
1090
+ 'key-duplicates: disable\n ' )
1028
1091
1029
1092
key_strings = ('---\n '
1030
1093
'true: 2\n '
@@ -1064,13 +1127,17 @@ def test_only_when_needed_single_quotes(self):
1064
1127
' line 2\n '
1065
1128
': 35\n '
1066
1129
'?\n '
1130
+ ' "line 1\n '
1131
+ ' line 2"\n '
1132
+ ': 37\n '
1133
+ '?\n '
1067
1134
' "line 1\\ \n '
1068
1135
' line 2"\n '
1069
1136
': 39\n ' )
1070
1137
self .check (key_strings , conf ,
1071
1138
problem1 = (5 , 1 ), problem2 = (6 , 1 ), problem3 = (7 , 1 ),
1072
1139
problem4 = (8 , 1 ), problem5 = (21 , 3 ), problem6 = (23 , 10 ),
1073
- problem7 = (37 , 3 ))
1140
+ problem7 = (37 , 3 ), problem8 = ( 41 , 3 ) )
1074
1141
1075
1142
def test_only_when_needed_corner_cases (self ):
1076
1143
conf = ('quoted-strings:\n '
0 commit comments