core3: boolean properties can be set explicitely

This commit is contained in:
Wojtek Porczyk 2015-09-25 21:49:59 +02:00
parent b4d51b016b
commit 17ac6cb225
2 changed files with 11 additions and 8 deletions

View File

@ -757,13 +757,16 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name
:py:obj:`True`. :py:obj:`True`.
''' # pylint: disable=bad-staticmethod-argument,unused-argument ''' # pylint: disable=bad-staticmethod-argument,unused-argument
lcvalue = value.lower() if isinstance(value, basestring):
if lcvalue in ('0', 'no', 'false'): lcvalue = value.lower()
return False if lcvalue in ('0', 'no', 'false', 'off'):
if lcvalue in ('1', 'yes', 'true'): return False
return True if lcvalue in ('1', 'yes', 'true', 'on'):
raise ValueError( return True
'Invalid literal for boolean property: {!r}'.format(value)) raise ValueError(
'Invalid literal for boolean property: {!r}'.format(value))
return bool(value)

View File

@ -68,7 +68,7 @@ class TC_90_globals(qubes.tests.QubesTestCase):
qid=0, name='dom0', internal='False') qid=0, name='dom0', internal='False')
self.assertFalse(flag(None, vm)) self.assertFalse(flag(None, vm))
vm.internal = 'True' vm.internal = True
self.assertTrue(flag(None, vm)) self.assertTrue(flag(None, vm))