Fixed benedict yaml representer. #43
This commit is contained in:
parent
c1172d8cc0
commit
a121c9da9e
|
@ -270,3 +270,10 @@ class benedict(KeypathDict, IODict, ParseDict):
|
|||
Remove duplicated values from the current dict instance.
|
||||
"""
|
||||
_unique(self)
|
||||
|
||||
|
||||
# fix benedict yaml representer - #43
|
||||
from yaml import SafeDumper
|
||||
from yaml.representer import SafeRepresenter
|
||||
|
||||
SafeDumper.yaml_representers[cls] = SafeRepresenter.represent_dict
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
from benedict import benedict
|
||||
|
||||
import unittest
|
||||
import yaml
|
||||
|
||||
|
||||
class github_issue_0043_test_case(unittest.TestCase):
|
||||
|
@ -21,3 +22,8 @@ class github_issue_0043_test_case(unittest.TestCase):
|
|||
level2: Hello world
|
||||
"""
|
||||
self.assertEqual(s, r)
|
||||
|
||||
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"}})))
|
||||
|
|
Loading…
Reference in New Issue