mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #37279 from gtmanfred/2016.3
initialize super class of NamespacedDictWrapper
This commit is contained in:
commit
1a4833b3a1
@ -170,6 +170,7 @@ class NamespacedDictWrapper(collections.MutableMapping, dict):
|
||||
self.pre_keys = (pre_keys,)
|
||||
else:
|
||||
self.pre_keys = pre_keys
|
||||
super(NamespacedDictWrapper, self).__init__(self._dict())
|
||||
|
||||
def _dict(self):
|
||||
r = self.__dict
|
||||
|
@ -5,6 +5,7 @@
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import json
|
||||
import tornado.stack_context
|
||||
import tornado.gen
|
||||
from tornado.testing import AsyncTestCase, gen_test
|
||||
@ -185,3 +186,13 @@ class NamespacedDictWrapperTests(TestCase):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, ('prefix', 'foo'))
|
||||
self.assertEqual(w['bar'], 'baz')
|
||||
|
||||
def test_json_dumps_single_key(self):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, 'prefix')
|
||||
self.assertEqual(json.dumps(w), '{"foo": {"bar": "baz"}}')
|
||||
|
||||
def test_json_dumps_multiple_key(self):
|
||||
self._dict['prefix'] = {'foo': {'bar': 'baz'}}
|
||||
w = NamespacedDictWrapper(self._dict, ('prefix', 'foo'))
|
||||
self.assertEqual(json.dumps(w), '{"bar": "baz"}')
|
||||
|
Loading…
Reference in New Issue
Block a user