Fix `toml` encoding circular reference error. #110
This commit is contained in:
parent
6761f54e45
commit
195ed03ae1
|
@ -18,5 +18,5 @@ class TOMLSerializer(AbstractSerializer):
|
|||
return data
|
||||
|
||||
def encode(self, d, **kwargs):
|
||||
data = toml.dumps(d, **kwargs)
|
||||
data = toml.dumps(dict(d), **kwargs)
|
||||
return data
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from benedict import benedict
|
||||
|
||||
# import toml
|
||||
import unittest
|
||||
|
||||
|
||||
class github_issue_0110_test_case(unittest.TestCase):
|
||||
"""
|
||||
This class describes a github issue 0110 test case.
|
||||
https://github.com/fabiocaccamo/python-benedict/issues/110
|
||||
|
||||
To run this specific test:
|
||||
- Run python -m unittest tests.github.test_issue_0110
|
||||
"""
|
||||
|
||||
def test_toml_circular_reference_detected(self):
|
||||
d = {"a": {"b": {"c": 1}}}
|
||||
d["e"] = benedict({"f": 2})
|
||||
|
||||
b = benedict()
|
||||
b.update(d)
|
||||
# b.merge(d)
|
||||
|
||||
t = b.to_toml()
|
||||
print(t)
|
Loading…
Reference in New Issue