File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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' : {}}})
You can’t perform that action at this time.
0 commit comments