ImmutableMap: repr recursively

This commit is contained in:
Jakub Warmuz 2015-02-07 07:45:33 +00:00
parent 13128464aa
commit 9d52cb6adc
No known key found for this signature in database
GPG key ID: 2A7BAD3A489B52EA
2 changed files with 2 additions and 1 deletions

View file

@ -123,5 +123,5 @@ class ImmutableMap(object): # pylint: disable=too-few-public-methods
def __repr__(self):
return '{0}({1})'.format(self.__class__.__name__, ', '.join(
'{0}={1}'.format(slot, getattr(self, slot))
'{0}={1!r}'.format(slot, getattr(self, slot))
for slot in self.__slots__))

View file

@ -160,6 +160,7 @@ class ImmutableMapTest(unittest.TestCase):
self.assertEqual('A(x=1, y=2)', repr(self.a1))
self.assertEqual('A(x=1, y=2)', repr(self.a1_swap))
self.assertEqual('B(x=1, y=2)', repr(self.b))
self.assertEqual("B(x='foo', y='bar')", repr(self.B(x='foo', y='bar')))
if __name__ == '__main__':