Explicitly set default_flow_style to False

In PyYAML 5.1 they changed this default in the library. Because
we weren't explicitly setting it, this broke our unit tests.
Since default_flow_style=False is usually what you want (hence why
PyYAML changed it), let's set it explicitly.

Also note that this was already being set for dump, but not for
dumps. This is also more consistent.

Change-Id: I3f7dfce5ceb5d3b802878c410406994cbb0988b6
This commit is contained in:
Ben Nemec 2019-05-02 17:00:42 +00:00
parent 0ceb4dbb6b
commit 448807a706
2 changed files with 7 additions and 5 deletions

View File

@ -55,10 +55,12 @@ class BehaviorTestCase(base.BaseTestCase):
]
dumped = yaml.dumps(payload)
expected = textwrap.dedent('''\
- {foo: bar}
- {list: null}
- [one, two]
- {check: yaml, in: test}
- foo: bar
- list: null
- - one
- two
- check: yaml
in: test
''')
self.assertEqual(dumped, expected)

View File

@ -67,7 +67,7 @@ def dumps(obj, is_safe=True):
yaml_dumper = yaml.CSafeDumper
else:
yaml_dumper = yaml.SafeDumper
return yaml.dump(obj, Dumper=yaml_dumper)
return yaml.dump(obj, default_flow_style=False, Dumper=yaml_dumper)
def dump(obj, fp, is_safe=True):