python-benedict/tests/github/test_issue_0043.py

29 lines
749 B
Python
Raw Permalink Normal View History

import unittest
2020-11-30 10:26:20 +00:00
import yaml
from benedict import benedict
class github_issue_0043_test_case(unittest.TestCase):
"""
2022-02-13 10:35:43 +00:00
This class describes a github issue 0043 test case.
https://github.com/fabiocaccamo/python-benedict/issues/43
To run this specific test:
- Run python -m unittest tests.github.test_issue_0043
"""
def test_to_yaml(self):
b = benedict({"level1": {"level2": "Hello world"}})
s = b.to_yaml()
r = """level1:
level2: Hello world
"""
self.assertEqual(s, r)
2020-11-30 10:26:20 +00:00
def test_dict_compatibility(self):
yaml.safe_dump(dict(benedict({})))
yaml.safe_dump(dict(benedict({"level1": None})))
yaml.safe_dump(dict(benedict({"level1": {"level2": "blablabla"}})))