Skip to content

Commit

Permalink
React to flake8 linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmknoble committed Dec 3, 2024
1 parent d176efa commit 4cb3eed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/rules/test_quoted_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from tests.common import RuleTestCase
from yaml.reader import ReaderError as yaml_reader_ReaderError

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


class QuotedValuesTestCase(RuleTestCase):
Expand Down Expand Up @@ -479,17 +479,21 @@ def test_only_when_needed_extras(self):
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',
# double-quoted escaped special chars: ok
'k1: "\\u001b"\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')
# double-quoted unescaped special chars: yuck"
'k1: "\u001b"\n')
yamltext2 = ('---\n'
"k1: '\u001b (single-quoted unescaped special characters are not ok)'\n")
# single-quoted unescaped special chars: yuck"
"k1: '\u001b'\n")
yamltext3 = ('---\n'
'k1: \u001b (unquoted unescaped special characters are not ok)\n')
# unquoted unescaped special chars: yuck"
'k1: \u001b\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)
Expand Down

0 comments on commit 4cb3eed

Please sign in to comment.