From 658d61ecee175036b81b0c6897587c0506a07679 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Thu, 9 Jul 2015 08:48:21 -0400 Subject: [PATCH] Use __iter__ method of Attributes class in __repr__ method Join method expects list, but six.itervalues(self._attributes) returns a Attribute instance, so we should use own __iter__ method for building list of values. Closes-Bug: #1473974 Change-Id: I7c5d4a5a8d0142156c3416347940b9e90ed8df5c --- heat/engine/attributes.py | 2 +- heat/tests/test_attributes.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/heat/engine/attributes.py b/heat/engine/attributes.py index 477b912473..fae19a80b3 100644 --- a/heat/engine/attributes.py +++ b/heat/engine/attributes.py @@ -233,7 +233,7 @@ class Attributes(collections.Mapping): def __repr__(self): return ("Attributes for %s:\n\t" % self._resource_name + - '\n\t'.join(six.itervalues(self._attributes))) + '\n\t'.join(six.itervalues(self))) def select_from_attribute(attribute_value, path): diff --git a/heat/tests/test_attributes.py b/heat/tests/test_attributes.py index 2c7c7fb86f..9f2f17d7f5 100644 --- a/heat/tests/test_attributes.py +++ b/heat/tests/test_attributes.py @@ -110,6 +110,15 @@ class AttributesTest(common.HeatTestCase): test_resolver) self.assertEqual("value1", attribs['test1']) + def test_attributes_representation(self): + """Test that attributes are displayed correct.""" + test_resolver = lambda x: "value1" + attribs = attributes.Attributes('test resource', + self.attributes_schema, + test_resolver) + msg = 'Attributes for test resource:\n\tvalue1\n\tvalue1\n\tvalue1' + self.assertEqual(msg, str(attribs)) + def test_get_attribute_none(self): """Test that we get the attribute values we expect.""" test_resolver = lambda x: None