#NEWLINE# def test_boolean_constructors( ) : #NEWLINE# #INDENT# bad_inputs = [ '' , 'a b c' , unicodey ( 'a b c' ) , unicodey ( '' ) , '1e5' , ' 0' ] #NEWLINE# good_inputs = [ unicodey ( '{{foo}}' ) , ( - 1 ) , 0 , 1 , 2 , 'true' , 'false' , '0' , '1' , True , False ] #NEWLINE# for input in bad_inputs : #NEWLINE# #INDENT# with pytest . raises ( SimpleObject . CoercionError ) : #NEWLINE# #INDENT# str ( Boolean ( input ) ) #NEWLINE# #UNINDENT# with pytest . raises ( SimpleObject . CoercionError ) : #NEWLINE# #INDENT# repr ( Boolean ( input ) ) #NEWLINE# #UNINDENT# #UNINDENT# for input in good_inputs : #NEWLINE# #INDENT# str ( Boolean ( input ) ) #NEWLINE# repr ( Boolean ( input ) ) #NEWLINE# #UNINDENT# assert ( Boolean ( 0 ) == Boolean ( False ) ) #NEWLINE# assert ( Boolean ( 0 ) != Boolean ( True ) ) #NEWLINE# assert ( Boolean ( 1 ) == Boolean ( True ) ) #NEWLINE# assert ( Boolean ( 1 ) != Boolean ( False ) ) #NEWLINE# assert ( Boolean ( '0' ) == Boolean ( False ) ) #NEWLINE# assert ( Boolean ( '1' ) == Boolean ( True ) ) #NEWLINE# assert ( not Boolean ( '2' ) . check ( ) . ok ( ) ) #NEWLINE# assert Boolean ( 123 ) . check ( ) . ok ( ) #NEWLINE# assert Boolean ( 'true' ) . check ( ) . ok ( ) #NEWLINE# assert Boolean ( 'false' ) . check ( ) . ok ( ) #NEWLINE# assert Boolean ( True ) . check ( ) . ok ( ) #NEWLINE# assert Boolean ( False ) . check ( ) . ok ( ) #NEWLINE# assert ( not Boolean ( '{{foo}}' ) . check ( ) . ok ( ) ) #NEWLINE# assert Boolean ( '{{foo}}' ) . bind ( foo = True ) . check ( ) . ok ( )