Skip to content

Commit 740e0c1

Browse files
committed
Enforced tests (thanks to @simkimsia). #60
1 parent 8e7814c commit 740e0c1

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/github/test_issue_0059.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from benedict import benedict
4+
5+
import unittest
6+
7+
8+
class github_issue_0059_test_case(unittest.TestCase):
9+
10+
"""
11+
https://github.com/fabiocaccamo/python-benedict/issues/59
12+
13+
To run this specific test:
14+
- Run python -m unittest tests.github.test_issue_0059
15+
"""
16+
def test_init_with_empty_dict_then_merge_with_dict_should_affect_both_dicts(self):
17+
initial_empty_dict = {}
18+
the_benedict = benedict(initial_empty_dict)
19+
the_benedict.merge({"foo": "bar"})
20+
21+
self.assertEqual(initial_empty_dict, {"foo": "bar"})
22+
self.assertEqual(the_benedict, {"foo": "bar"})
23+
24+
def test_init_empty_dict_then_assign_another_empty_dict_as_first_key_should_work(self):
25+
d = benedict()
26+
# these two lines are inefficient
27+
# d["a"] = {"b": {}} is better. Regardless, will test both
28+
d["a"] = {}
29+
d["a"]["b"] = {}
30+
31+
self.assertEqual(d, {'a': {'b': {}}})
32+
33+
d2 = benedict()
34+
d2["a"] = {"b": {}}
35+
36+
self.assertEqual(d2, {'a': {'b': {}}})

0 commit comments

Comments
 (0)