@ -43,13 +43,13 @@ class TestAttributes(base.BaseTestCase):
def test_is_attr_set ( self ) :
data = attributes . ATTR_NOT_SPECIFIED
self . assert Is ( attributes . is_attr_set ( data ) , False )
self . assert False ( attributes . is_attr_set ( data ) )
data = None
self . assert Is ( attributes . is_attr_set ( data ) , False )
self . assert False ( attributes . is_attr_set ( data ) )
data = " I ' m set "
self . assert Is ( attributes . is_attr_set ( data ) , True )
self . assert True ( attributes . is_attr_set ( data ) )
def test_validate_values ( self ) :
msg = attributes . _validate_values ( 4 , [ 4 , 6 ] )
@ -647,7 +647,7 @@ class TestAttributes(base.BaseTestCase):
self . assertIsNone ( msg )
# Explicitly comparing with literal 'True' as assertTrue
# succeeds also for 'true'
self . assert Is( True , dictionary [ ' key_bool ' ] )
self . assert True( dictionary [ ' key_bool ' ] )
def test_subdictionary ( self ) :
dictionary , constraints = self . _construct_dict_and_constraints ( )
@ -693,23 +693,23 @@ class TestAttributes(base.BaseTestCase):
class TestConvertToBoolean ( base . BaseTestCase ) :
def test_convert_to_boolean_bool ( self ) :
self . assert Is ( attributes . convert_to_boolean ( True ) , True )
self . assert Is ( attributes . convert_to_boolean ( False ) , False )
self . assert True ( attributes . convert_to_boolean ( True ) )
self . assert False ( attributes . convert_to_boolean ( False ) )
def test_convert_to_boolean_int ( self ) :
self . assert Is ( attributes . convert_to_boolean ( 0 ) , False )
self . assert Is ( attributes . convert_to_boolean ( 1 ) , True )
self . assert False ( attributes . convert_to_boolean ( 0 ) )
self . assert True ( attributes . convert_to_boolean ( 1 ) )
self . assertRaises ( n_exc . InvalidInput ,
attributes . convert_to_boolean ,
7 )
def test_convert_to_boolean_str ( self ) :
self . assert Is ( attributes . convert_to_boolean ( ' True ' ) , True )
self . assert Is ( attributes . convert_to_boolean ( ' true ' ) , True )
self . assert Is ( attributes . convert_to_boolean ( ' False ' ) , False )
self . assert Is ( attributes . convert_to_boolean ( ' false ' ) , False )
self . assert Is ( attributes . convert_to_boolean ( ' 0 ' ) , False )
self . assert Is ( attributes . convert_to_boolean ( ' 1 ' ) , True )
self . assert True ( attributes . convert_to_boolean ( ' True ' ) )
self . assert True ( attributes . convert_to_boolean ( ' true ' ) )
self . assert False ( attributes . convert_to_boolean ( ' False ' ) )
self . assert False ( attributes . convert_to_boolean ( ' false ' ) )
self . assert False ( attributes . convert_to_boolean ( ' 0 ' ) )
self . assert True ( attributes . convert_to_boolean ( ' 1 ' ) )
self . assertRaises ( n_exc . InvalidInput ,
attributes . convert_to_boolean ,
' 7 ' )