<s> from . . import CleoTestCase <EOL> from cleo . validators import ValidatorSet , Boolean , Enum , Integer , Float , Range <EOL> class ValidatorSetTestCase ( CleoTestCase ) : <EOL> def test_init ( self ) : <EOL> validator_set = ValidatorSet ( ) <EOL> self . assertEqual ( { } , validator_set . validators ) <EOL> validator_set = ValidatorSet ( [ Boolean ] ) <EOL> self . assertEqual ( Boolean , validator_set . validators [ '<STR_LIT>' ] ) <EOL> def test_register ( self ) : <EOL> validator_set = ValidatorSet ( ) <EOL> validator_set . register ( Boolean ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( validator_set . validators ) ) <EOL> self . assertEqual ( Boolean , validator_set . validators [ '<STR_LIT>' ] ) <EOL> validator_set . register ( Enum ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( validator_set . validators ) ) <EOL> self . assertEqual ( Enum , validator_set . validators [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( Enum , validator_set . validators [ '<STR_LIT>' ] ) <EOL> def test_register_with_non_validator ( self ) : <EOL> validator_set = ValidatorSet ( ) <EOL> self . assertRaises ( <EOL> Exception , <EOL> validator_set . register , <EOL> '<STR_LIT:foo>' <EOL> ) <EOL> class Foo ( object ) : <EOL> name = '<STR_LIT:foo>' <EOL> self . assertRaises ( <EOL> Exception , <EOL> validator_set . register , <EOL> Foo <EOL> ) <EOL> def test_get ( self ) : <EOL> validator_set = ValidatorSet ( [ <EOL> Boolean , <EOL> Enum <EOL> ] ) <EOL> self . assertIsInstance ( validator_set . get ( '<STR_LIT>' ) , Boolean ) <EOL> self . assertIsInstance ( validator_set . get ( Boolean ( ) ) , Boolean ) <EOL> self . assertIsNone ( validator_set . get ( '<STR_LIT:string>' ) ) <EOL> try : <EOL> validator_set . get ( '<STR_LIT:foo>' ) <EOL> self . fail ( '<STR_LIT>' ) <EOL> except Exception as e : <EOL> self . assertRegex ( <EOL> str ( e ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_get_native_types ( self ) : <EOL> validator_set = ValidatorSet ( ) <EOL> self . assertIsInstance ( validator_set . get ( bool ) , Boolean ) <EOL> self . assertIsInstance ( validator_set . get ( int ) , Integer ) <EOL> self . assertIsInstance ( validator_set . get ( float ) , Float ) <EOL> self . assertIsNone ( validator_set . get ( str ) ) </s>
