mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
add more edge case handling for yaml unsafe marking
This commit is contained in:
parent
31ea55acb9
commit
f8211b0588
@ -20,6 +20,18 @@ def test_raw_string():
|
||||
assert safe_dump('foo') == "!unsafe 'foo'\n"
|
||||
|
||||
|
||||
def test_kv_null():
|
||||
assert safe_dump({'a': None}) == "!unsafe 'a': null\n"
|
||||
|
||||
|
||||
def test_kv_null_safe():
|
||||
assert safe_dump({'a': None}, {'a': None}) == "a: null\n"
|
||||
|
||||
|
||||
def test_kv_null_unsafe():
|
||||
assert safe_dump({'a': ''}, {'a': None}) == "!unsafe 'a': !unsafe ''\n"
|
||||
|
||||
|
||||
def test_kv_int():
|
||||
assert safe_dump({'a': 1}) == "!unsafe 'a': 1\n"
|
||||
|
||||
|
@ -58,7 +58,7 @@ def safe_dump(x, safe_dict=None):
|
||||
# equality matches (and consider those branches safe)
|
||||
for k, v in x.items():
|
||||
dumper = yaml.SafeDumper
|
||||
if safe_dict.get(k) != v:
|
||||
if k not in safe_dict or safe_dict.get(k) != v:
|
||||
dumper = SafeStringDumper
|
||||
yamls.append(yaml.dump_all(
|
||||
[{k: v}],
|
||||
|
Loading…
Reference in New Issue
Block a user