mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #34220 from LeadSift/develop
Fixes #34181 no more newlines in long yaml encodes
This commit is contained in:
commit
f65535a307
@ -16,7 +16,7 @@ def yaml_dquote(text):
|
||||
quote characters.
|
||||
'''
|
||||
with io.StringIO() as ostream:
|
||||
yemitter = yaml.emitter.Emitter(ostream)
|
||||
yemitter = yaml.emitter.Emitter(ostream, width=six.MAXSIZE)
|
||||
yemitter.write_double_quoted(six.text_type(text))
|
||||
return ostream.getvalue()
|
||||
|
||||
@ -28,7 +28,7 @@ def yaml_squote(text):
|
||||
quote characters.
|
||||
'''
|
||||
with io.StringIO() as ostream:
|
||||
yemitter = yaml.emitter.Emitter(ostream)
|
||||
yemitter = yaml.emitter.Emitter(ostream, width=six.MAXSIZE)
|
||||
yemitter.write_single_quoted(six.text_type(text))
|
||||
return ostream.getvalue()
|
||||
|
||||
|
@ -547,10 +547,18 @@ class UtilsTestCase(TestCase):
|
||||
for teststr in (r'"\ []{}"',):
|
||||
self.assertEqual(teststr, yaml.safe_load(utils.yamlencoding.yaml_dquote(teststr)))
|
||||
|
||||
def test_yaml_dquote_doesNotAddNewLines(self):
|
||||
teststr = '"' * 100
|
||||
self.assertNotIn('\n', utils.yamlencoding.yaml_dquote(teststr))
|
||||
|
||||
def test_yaml_squote(self):
|
||||
ret = utils.yamlencoding.yaml_squote(r'"')
|
||||
self.assertEqual(ret, r"""'"'""")
|
||||
|
||||
def test_yaml_squote_doesNotAddNewLines(self):
|
||||
teststr = "'" * 100
|
||||
self.assertNotIn('\n', utils.yamlencoding.yaml_squote(teststr))
|
||||
|
||||
def test_yaml_encode(self):
|
||||
for testobj in (None, True, False, '[7, 5]', '"monkey"', 5, 7.5, "2014-06-02 15:30:29.7"):
|
||||
self.assertEqual(testobj, yaml.safe_load(utils.yamlencoding.yaml_encode(testobj)))
|
||||
|
Loading…
Reference in New Issue
Block a user