mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #18447 -- Made LazyObject unwrap on dict access.
Thanks Roman Gladkov and Zbigniew Siciarz.
This commit is contained in:
parent
7cf0f04230
commit
0efafa4c54
2 changed files with 24 additions and 1 deletions
|
@ -128,3 +128,13 @@ class TestUtilsSimpleLazyObject(TestCase):
|
|||
self.assertEqual(unpickled, x)
|
||||
self.assertEqual(six.text_type(unpickled), six.text_type(x))
|
||||
self.assertEqual(unpickled.name, x.name)
|
||||
|
||||
def test_dict(self):
|
||||
# See ticket #18447
|
||||
lazydict = SimpleLazyObject(lambda: {'one': 1})
|
||||
self.assertEqual(lazydict['one'], 1)
|
||||
lazydict['one'] = -1
|
||||
self.assertEqual(lazydict['one'], -1)
|
||||
del lazydict['one']
|
||||
with self.assertRaises(KeyError):
|
||||
lazydict['one']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue