How to use safe_dump method in molecule

Best Python code snippet using molecule_python

test_safe_yaml.py

Source:test_safe_yaml.py Github

copy

Full Screen

...5from awx.main.utils.safe_yaml import safe_dump6@pytest.mark.parametrize('value', [None, 1, 1.5, []])7def test_native_types(value):8 # Native non-string types should dump the same way that `yaml.safe_dump` does9 assert safe_dump(value) == yaml.safe_dump(value)10def test_empty():11 assert safe_dump({}) == ''12def test_raw_string():13 assert safe_dump('foo') == "!unsafe 'foo'\n"14def test_kv_null():15 assert safe_dump({'a': None}) == "!unsafe 'a': null\n"16def test_kv_null_safe():17 assert safe_dump({'a': None}, {'a': None}) == "a: null\n"18def test_kv_null_unsafe():19 assert safe_dump({'a': ''}, {'a': None}) == "!unsafe 'a': !unsafe ''\n"20def test_kv_int():21 assert safe_dump({'a': 1}) == "!unsafe 'a': 1\n"22def test_kv_float():23 assert safe_dump({'a': 1.5}) == "!unsafe 'a': 1.5\n"24def test_kv_unsafe():25 assert safe_dump({'a': 'b'}) == "!unsafe 'a': !unsafe 'b'\n"26def test_kv_unsafe_unicode():27 assert safe_dump({'a': u'🐉'}) == '!unsafe \'a\': !unsafe "\\U0001F409"\n'28def test_kv_unsafe_in_list():29 assert safe_dump({'a': ['b']}) == "!unsafe 'a':\n- !unsafe 'b'\n"30def test_kv_unsafe_in_mixed_list():31 assert safe_dump({'a': [1, 'b']}) == "!unsafe 'a':\n- 1\n- !unsafe 'b'\n"32def test_kv_unsafe_deep_nesting():33 yaml = safe_dump({'a': [1, [{'b': {'c': [{'d': 'e'}]}}]]})34 for x in ('a', 'b', 'c', 'd', 'e'):35 assert "!unsafe '{}'".format(x) in yaml36def test_kv_unsafe_multiple():37 assert safe_dump({'a': 'b', 'c': 'd'}) == '\n'.join([38 "!unsafe 'a': !unsafe 'b'",39 "!unsafe 'c': !unsafe 'd'",40 ""41 ])42def test_safe_marking():43 assert safe_dump({'a': 'b'}, safe_dict={'a': 'b'}) == "a: b\n"44def test_safe_marking_mixed():45 assert safe_dump({'a': 'b', 'c': 'd'}, safe_dict={'a': 'b'}) == '\n'.join([46 "a: b",47 "!unsafe 'c': !unsafe 'd'",48 ""49 ])50def test_safe_marking_deep_nesting():51 deep = {'a': [1, [{'b': {'c': [{'d': 'e'}]}}]]}52 yaml = safe_dump(deep, deepcopy(deep))53 for x in ('a', 'b', 'c', 'd', 'e'):54 assert "!unsafe '{}'".format(x) not in yaml55def test_deep_diff_unsafe_marking():56 deep = {'a': [1, [{'b': {'c': [{'d': 'e'}]}}]]}57 jt_vars = deepcopy(deep)58 deep['a'][1][0]['b']['z'] = 'not safe'59 yaml = safe_dump(deep, jt_vars)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful