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`.
''' # pylint: disable=bad-staticmethod-argument,unused-argument
lcvalue = value.lower()
if lcvalue in ('0', 'no', 'false'):
return False
if lcvalue in ('1', 'yes', 'true'):
return True
raise ValueError(
'Invalid literal for boolean property: {!r}'.format(value))
if isinstance(value, basestring):
lcvalue = value.lower()
if lcvalue in ('0', 'no', 'false', 'off'):
return False
if lcvalue in ('1', 'yes', 'true', 'on'):
return True
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')
self.assertFalse(flag(None, vm))
vm.internal = 'True'
vm.internal = True
self.assertTrue(flag(None, vm))