summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Kibardin <gkibardin@mirantis.com>2017-04-07 10:25:27 +0300
committerGeorgy Kibardin <gkibardin@mirantis.com>2017-04-10 13:44:47 +0300
commitb8e2606dafeaff409f9cef22af18b4262f07f8fb (patch)
tree99dd0022db6cbffb0a899bc14734c4ee53434be1
parent9dabe063699799ebac5c42178650f09c11e0febe (diff)
Override keys() with a function, not an attribute
By mistake keys function has been overriden by a value. Change-Id: I713bddcfb66c4835d477972ece7e0983d263377f Closes-Bug: #1666913
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+2: Alexander Kislitsky <akislitsky@mirantis.com> Code-Review+1: Michael Polenchuk <mpolenchuk@mirantis.com> Code-Review+2: Aleksey Kasatkin <akasatkin@mirantis.com> Workflow+1: Alexander Kislitsky <akislitsky@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 13 Apr 2017 11:32:20 +0000 Reviewed-on: https://review.openstack.org/454574 Project: openstack/fuel-web Branch: refs/heads/master
-rw-r--r--nailgun/nailgun/test/unit/test_uniondict.py6
-rw-r--r--nailgun/nailgun/utils/uniondict.py6
2 files changed, 9 insertions, 3 deletions
diff --git a/nailgun/nailgun/test/unit/test_uniondict.py b/nailgun/nailgun/test/unit/test_uniondict.py
index 038f108..0875b30 100644
--- a/nailgun/nailgun/test/unit/test_uniondict.py
+++ b/nailgun/nailgun/test/unit/test_uniondict.py
@@ -103,3 +103,9 @@ f: 6"""
103 def test_repr(self): 103 def test_repr(self):
104 d = UnionDict(self.D1, self.D2, self.D3) 104 d = UnionDict(self.D1, self.D2, self.D3)
105 self.assertEquals(eval(repr(d)), self.D) 105 self.assertEquals(eval(repr(d)), self.D)
106
107 def test_keys(self):
108 ud = UnionDict({'a': 1, 'b': 2, 'c': 3},
109 {'b': 2, 'c': 3, 'd': 4},
110 {'e': 5})
111 self.assertEquals(ud.keys(), {'a', 'b', 'c', 'd', 'e'})
diff --git a/nailgun/nailgun/utils/uniondict.py b/nailgun/nailgun/utils/uniondict.py
index 02511ab..a4a315e 100644
--- a/nailgun/nailgun/utils/uniondict.py
+++ b/nailgun/nailgun/utils/uniondict.py
@@ -31,7 +31,7 @@ class UnionDict(collections.Mapping):
31 31
32 self.dicts = list(dicts) 32 self.dicts = list(dicts)
33 self.dicts.reverse() 33 self.dicts.reverse()
34 self.keys = set(itertools.chain.from_iterable(dicts)) 34 self.keys = lambda: set(itertools.chain.from_iterable(dicts))
35 35
36 def __getitem__(self, key): 36 def __getitem__(self, key):
37 values = [] 37 values = []
@@ -54,10 +54,10 @@ class UnionDict(collections.Mapping):
54 return UnionDict(*values) 54 return UnionDict(*values)
55 55
56 def __iter__(self): 56 def __iter__(self):
57 return iter(self.keys) 57 return iter(self.keys())
58 58
59 def __len__(self): 59 def __len__(self):
60 return len(self.keys) 60 return len(self.keys())
61 61
62 def __repr__(self): 62 def __repr__(self):
63 items = ['{!r}: {!r}'.format(k, v) for k, v in self.items()] 63 items = ['{!r}: {!r}'.format(k, v) for k, v in self.items()]