mirror of
https://github.com/romanz/amodem.git
synced 2026-02-06 08:38:06 +08:00
common: fix __repr__ on AttributeHolder
This commit is contained in:
@@ -80,4 +80,6 @@ class AttributeHolder(object):
|
||||
self.__dict__.update(d)
|
||||
|
||||
def __repr__(self):
|
||||
return '{}({})'.format(self.__class__.__name__, self.__dict__)
|
||||
items = sorted(self.__dict__.items())
|
||||
args = ', '.join('{0}={1}'.format(k, v) for k, v in items)
|
||||
return '{}({})'.format(self.__class__.__name__, args)
|
||||
|
||||
@@ -51,3 +51,11 @@ def test_izip():
|
||||
x = range(10)
|
||||
y = range(-10, 0)
|
||||
assert list(common.izip([x, y])) == list(zip(x, y))
|
||||
|
||||
|
||||
def test_holder():
|
||||
d = {'x': 1, 'y': 2.3}
|
||||
a = common.AttributeHolder(d)
|
||||
assert a.x == d['x']
|
||||
assert a.y == d['y']
|
||||
assert repr(a) == 'AttributeHolder(x=1, y=2.3)'
|
||||
|
||||
Reference in New Issue
Block a user