diff --git a/CHANGELOG.md b/CHANGELOG.md index e023b12dcbc00b759a01d9cc97f7a611cbe03542..5960160f1185f09e4cf83f5781b90cb4aba7aa8b 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 268c086e1355621bb4d2f8a567297cf56e6821ec..97578f7419d3f209404f9218de680dd9590e9693 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 878a76babb84951ecad79dfb938718750d3cf2ee..a5748928e5260e10dae75fd5d884b552d3f35eb3 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))