Skip to content

Commit

Permalink
Add repro test case for adrienverge#700
Browse files Browse the repository at this point in the history
  • Loading branch information
jmknoble committed Dec 3, 2024
1 parent 8513d9b commit 9b8ce28
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/rules/test_quoted_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from tests.common import RuleTestCase

from yamllint import config
from yaml.reader import ReaderError as yaml_reader_ReaderError


class QuotedValuesTestCase(RuleTestCase):
Expand Down Expand Up @@ -475,6 +476,24 @@ def test_only_when_needed_extras(self):
'- "foo bar"\n',
conf, problem1=(3, 3), problem2=(7, 3), problem3=(11, 3))

def test_only_when_needed_special_characters(self):
conf = 'quoted-strings: {required: only-when-needed}\n'
self.check('---\n'
'k1: "\\u001b (double-quoted backslash-escaped special characters are ok)"\n',
conf)

def test_only_when_needed_special_characters_exceptions(self):
conf = 'quoted-strings: {required: only-when-needed}\n'
yamltext1 = ('---\n'
'k1: "\u001b (double-quoted unescaped special characters are not ok)"\n')
yamltext2 = ('---\n'
"k1: '\u001b (single-quoted unescaped special characters are not ok)'\n")
yamltext3 = ('---\n'
'k1: \u001b (unquoted unescaped special characters are not ok)\n')
self.assertRaises(yaml_reader_ReaderError, self.check, yamltext1, conf)
self.assertRaises(yaml_reader_ReaderError, self.check, yamltext2, conf)
self.assertRaises(yaml_reader_ReaderError, self.check, yamltext3, conf)

def test_octal_values(self):
conf = 'quoted-strings: {required: true}\n'

Expand Down

0 comments on commit 9b8ce28

Please sign in to comment.