2021-08-11 09:18:56 +00:00
|
|
|
import unittest
|
|
|
|
|
2022-10-14 14:53:06 +00:00
|
|
|
from benedict import benedict
|
|
|
|
|
2021-08-11 09:18:56 +00:00
|
|
|
|
|
|
|
class github_issue_0059_test_case(unittest.TestCase):
|
|
|
|
"""
|
2022-02-13 10:35:43 +00:00
|
|
|
This class describes a github issue 0059 test case.
|
2021-08-11 09:18:56 +00:00
|
|
|
https://github.com/fabiocaccamo/python-benedict/issues/59
|
|
|
|
|
|
|
|
To run this specific test:
|
|
|
|
- Run python -m unittest tests.github.test_issue_0059
|
|
|
|
"""
|
2022-02-13 10:35:43 +00:00
|
|
|
|
2021-08-11 09:18:56 +00:00
|
|
|
def test_init_with_empty_dict_then_merge_with_dict_should_affect_both_dicts(self):
|
|
|
|
initial_empty_dict = {}
|
|
|
|
the_benedict = benedict(initial_empty_dict)
|
|
|
|
the_benedict.merge({"foo": "bar"})
|
|
|
|
self.assertEqual(initial_empty_dict, {"foo": "bar"})
|
|
|
|
self.assertEqual(the_benedict, {"foo": "bar"})
|
|
|
|
|
2022-02-13 10:35:43 +00:00
|
|
|
def test_init_empty_dict_then_assign_another_empty_dict_as_first_key_should_work(
|
|
|
|
self,
|
|
|
|
):
|
2021-08-11 09:18:56 +00:00
|
|
|
d = benedict()
|
|
|
|
# these two lines are inefficient
|
|
|
|
# d["a"] = {"b": {}} is better. Regardless, will test both
|
|
|
|
d["a"] = {}
|
|
|
|
d["a"]["b"] = {}
|
2022-02-13 10:35:43 +00:00
|
|
|
self.assertEqual(d, {"a": {"b": {}}})
|
2021-08-11 09:18:56 +00:00
|
|
|
|
|
|
|
d2 = benedict()
|
|
|
|
d2["a"] = {"b": {}}
|
2022-02-13 10:35:43 +00:00
|
|
|
self.assertEqual(d2, {"a": {"b": {}}})
|