Skip to content

Commit aa75d06

Browse files
committed
Add test case for issue #314.
1 parent a6fad4b commit aa75d06

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/github/test_issue_0314.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import unittest
2+
3+
import yaml
4+
5+
from benedict import benedict
6+
7+
8+
class github_issue_0314_test_case(unittest.TestCase):
9+
"""
10+
This class describes a github issue 0314 test case.
11+
https://github.com/fabiocaccamo/python-benedict/issues/294
12+
13+
To run this specific test:
14+
- Run python -m unittest tests.github.test_issue_0314
15+
"""
16+
17+
def test_yaml_serializer_produces_inconsistent_results(self):
18+
b = benedict({"foo": "foo"})
19+
b["hello.world"] = "hello world"
20+
21+
# output as custom object using yaml manually
22+
print(yaml.dump({"world": dict(b)}))
23+
24+
# output as custom object using yaml manually
25+
print(yaml.dump({"world": b}))
26+
27+
# output as normal dict using yaml manually
28+
print(yaml.dump({"world": b.dict()}))
29+
30+
# output as normal dict using benedict yaml serializer
31+
print(benedict({"world": b}).to_yaml())
32+
33+
self.assertEqual(
34+
yaml.dump({"world": b.dict()}),
35+
benedict({"world": b}).to_yaml(),
36+
)

0 commit comments

Comments
 (0)