From 740e0c1b852f474d25ddf2b9e3b40ce6fdfaf508 Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Wed, 11 Aug 2021 11:18:56 +0200 Subject: [PATCH] Enforced tests (thanks to @simkimsia). #60 --- tests/github/test_issue_0059.py | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/github/test_issue_0059.py diff --git a/tests/github/test_issue_0059.py b/tests/github/test_issue_0059.py new file mode 100644 index 0000000..2ff6c68 --- /dev/null +++ b/tests/github/test_issue_0059.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from benedict import benedict + +import unittest + + +class github_issue_0059_test_case(unittest.TestCase): + + """ + https://github.com/fabiocaccamo/python-benedict/issues/59 + + To run this specific test: + - Run python -m unittest tests.github.test_issue_0059 + """ + 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"}) + + def test_init_empty_dict_then_assign_another_empty_dict_as_first_key_should_work(self): + d = benedict() + # these two lines are inefficient + # d["a"] = {"b": {}} is better. Regardless, will test both + d["a"] = {} + d["a"]["b"] = {} + + self.assertEqual(d, {'a': {'b': {}}}) + + d2 = benedict() + d2["a"] = {"b": {}} + + self.assertEqual(d2, {'a': {'b': {}}})