From 09b25f7686f9dbd58860d5c8109bdd66d92b6cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sat, 15 Apr 2023 19:56:14 +0200 Subject: [PATCH] minor doc changes --- CHANGELOG.md | 4 +++- satella/coding/structures/dictionaries/dict_object.py | 3 +++ tests/test_coding/test_structures.py | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e023b12d..5960160f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ -# v2.23.2 \ No newline at end of file +# v2.23.2 + +* minor changes to DictObject's documentation diff --git a/satella/coding/structures/dictionaries/dict_object.py b/satella/coding/structures/dictionaries/dict_object.py index 268c086e..97578f74 100644 --- a/satella/coding/structures/dictionaries/dict_object.py +++ b/satella/coding/structures/dictionaries/dict_object.py @@ -10,6 +10,8 @@ class DictObject(dict): """ A dictionary wrapper that can be accessed by attributes. + Note that it still remains a completely valid dictionary! + You can use keys different than strings, but they will be inaccessible as attributes, and you will have to do subscription to get them. @@ -17,6 +19,7 @@ class DictObject(dict): >>> a = DictObject({'test': 5}) >>> self.assertEqual(a.test, 5) + >>> self.assertEqual(a['test'], 5) """ def __copy__(self): diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 878a76ba..a5748928 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -497,8 +497,11 @@ class TestStructures(unittest.TestCase): b = DictObject(a) b.c = 4 self.assertEqual(b.a, 5) + self.assertEqual(b['a'], 5) self.assertEqual(b.k, 3) + self.assertEqual(b['k'], 3) self.assertEqual(b.c, 4) + self.assertEqual(b['c'], 4) self.assertIn('DictObject', str(b)) self.assertIn('DictObject', repr(b)) -- GitLab