mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adding a negative test for new safe_load
This commit is contained in:
parent
4cb7f654b6
commit
bbd9921dbd
1 changed files with 12 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
|||
# TODO: header
|
||||
|
||||
import unittest
|
||||
|
||||
from yaml.scanner import ScannerError
|
||||
|
||||
from ansible.parsing.yaml import safe_load
|
||||
from ansible.parsing.yaml.objects import AnsibleMapping
|
||||
|
||||
|
@ -36,6 +39,11 @@ data3 = '''---
|
|||
list1key3: list1value3
|
||||
'''
|
||||
|
||||
bad_data1 = '''---
|
||||
foo: bar
|
||||
bam: baz
|
||||
'''
|
||||
|
||||
class TestSafeLoad(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -44,6 +52,10 @@ class TestSafeLoad(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_safe_load_bad(self):
|
||||
# test the loading of bad yaml data
|
||||
self.assertRaises(ScannerError, safe_load, bad_data1)
|
||||
|
||||
def test_safe_load(self):
|
||||
# test basic dictionary
|
||||
res = safe_load(data1)
|
||||
|
|
Loading…
Reference in a new issue