@@ -453,3 +453,106 @@ def test_octal_values(self):
453
453
'- "0o800"\n ' ,
454
454
conf ,
455
455
problem1 = (9 , 3 ), problem2 = (10 , 3 ))
456
+
457
+ def test_allow_quoted_quotes (self ):
458
+ conf = ('quoted-strings: {quote-type: single,\n '
459
+ ' required: false,\n '
460
+ ' allow-quoted-quotes: false}\n ' )
461
+ self .check ('---\n '
462
+ 'foo1: "[barbaz]"\n ' # fails
463
+ 'foo2: "[bar\' baz]"\n ' , # fails
464
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
465
+
466
+ conf = ('quoted-strings: {quote-type: single,\n '
467
+ ' required: false,\n '
468
+ ' allow-quoted-quotes: true}\n ' )
469
+ self .check ('---\n '
470
+ 'foo1: "[barbaz]"\n ' # fails
471
+ 'foo2: "[bar\' baz]"\n ' ,
472
+ conf , problem1 = (2 , 7 ))
473
+
474
+ conf = ('quoted-strings: {quote-type: single,\n '
475
+ ' required: true,\n '
476
+ ' allow-quoted-quotes: false}\n ' )
477
+ self .check ('---\n '
478
+ 'foo1: "[barbaz]"\n ' # fails
479
+ 'foo2: "[bar\' baz]"\n ' , # fails
480
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
481
+
482
+ conf = ('quoted-strings: {quote-type: single,\n '
483
+ ' required: true,\n '
484
+ ' allow-quoted-quotes: true}\n ' )
485
+ self .check ('---\n '
486
+ 'foo1: "[barbaz]"\n ' # fails
487
+ 'foo2: "[bar\' baz]"\n ' ,
488
+ conf , problem1 = (2 , 7 ))
489
+
490
+ conf = ('quoted-strings: {quote-type: single,\n '
491
+ ' required: only-when-needed,\n '
492
+ ' allow-quoted-quotes: false}\n ' )
493
+ self .check ('---\n '
494
+ 'foo1: "[barbaz]"\n ' # fails
495
+ 'foo2: "[bar\' baz]"\n ' , # fails
496
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
497
+
498
+ conf = ('quoted-strings: {quote-type: single,\n '
499
+ ' required: only-when-needed,\n '
500
+ ' allow-quoted-quotes: true}\n ' )
501
+ self .check ('---\n '
502
+ 'foo1: "[barbaz]"\n ' # fails
503
+ 'foo2: "[bar\' baz]"\n ' ,
504
+ conf , problem1 = (2 , 7 ))
505
+
506
+ conf = ('quoted-strings: {quote-type: double,\n '
507
+ ' required: false,\n '
508
+ ' allow-quoted-quotes: false}\n ' )
509
+ self .check ("---\n "
510
+ "foo1: '[barbaz]'\n " # fails
511
+ "foo2: '[bar\" baz]'\n " , # fails
512
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
513
+
514
+ conf = ('quoted-strings: {quote-type: double,\n '
515
+ ' required: false,\n '
516
+ ' allow-quoted-quotes: true}\n ' )
517
+ self .check ("---\n "
518
+ "foo1: '[barbaz]'\n " # fails
519
+ "foo2: '[bar\" baz]'\n " ,
520
+ conf , problem1 = (2 , 7 ))
521
+
522
+ conf = ('quoted-strings: {quote-type: double,\n '
523
+ ' required: true,\n '
524
+ ' allow-quoted-quotes: false}\n ' )
525
+ self .check ("---\n "
526
+ "foo1: '[barbaz]'\n " # fails
527
+ "foo2: '[bar\" baz]'\n " , # fails
528
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
529
+
530
+ conf = ('quoted-strings: {quote-type: double,\n '
531
+ ' required: true,\n '
532
+ ' allow-quoted-quotes: true}\n ' )
533
+ self .check ("---\n "
534
+ "foo1: '[barbaz]'\n " # fails
535
+ "foo2: '[bar\" baz]'\n " ,
536
+ conf , problem1 = (2 , 7 ))
537
+
538
+ conf = ('quoted-strings: {quote-type: double,\n '
539
+ ' required: only-when-needed,\n '
540
+ ' allow-quoted-quotes: false}\n ' )
541
+ self .check ("---\n "
542
+ "foo1: '[barbaz]'\n " # fails
543
+ "foo2: '[bar\" baz]'\n " , # fails
544
+ conf , problem1 = (2 , 7 ), problem2 = (3 , 7 ))
545
+
546
+ conf = ('quoted-strings: {quote-type: double,\n '
547
+ ' required: only-when-needed,\n '
548
+ ' allow-quoted-quotes: true}\n ' )
549
+ self .check ("---\n "
550
+ "foo1: '[barbaz]'\n " # fails
551
+ "foo2: '[bar\" baz]'\n " ,
552
+ conf , problem1 = (2 , 7 ))
553
+
554
+ conf = ('quoted-strings: {quote-type: any}\n ' )
555
+ self .check ("---\n "
556
+ "foo1: '[barbaz]'\n "
557
+ "foo2: '[bar\" baz]'\n " ,
558
+ conf )
0 commit comments