grc: fixes in evaluated properties

This commit is contained in:
Sebastian Koslowski 2018-09-22 14:33:10 -07:00 committed by Martin Braun
parent e5bee3d4d5
commit 45d5f5efb7
2 changed files with 4 additions and 1 deletions

View File

@ -66,8 +66,9 @@ class Evaluated(object):
def __set__(self, instance, value):
attribs = instance.__dict__
value = value or self.default
if isinstance(value, six.text_type) and value.startswith('${') and value.endswith('}'):
if isinstance(value, six.string_types) and value.startswith('${') and value.endswith('}'):
attribs[self.name_raw] = value[2:-1].strip()
attribs.pop(self.name, None) # reset previous eval result
else:
attribs[self.name] = type(self.default)(value)

View File

@ -56,6 +56,8 @@ def test_evaled():
assert a.foo == 11 and a.foo == 11
assert a.called['foo'] == 2
assert not a.errors
a.foo = u'${ 10 + 2 }'
assert a.foo == 12
def test_evaled_with_default():