<s> from __future__ import unicode_literals <EOL> import pickle <EOL> from django . forms import BooleanField , ValidationError <EOL> from django . test import SimpleTestCase <EOL> class BooleanFieldTest ( SimpleTestCase ) : <EOL> def test_booleanfield_clean_1 ( self ) : <EOL> f = BooleanField ( ) <EOL> with self . assertRaisesMessage ( ValidationError , "<STR_LIT>" ) : <EOL> f . clean ( '<STR_LIT>' ) <EOL> with self . assertRaisesMessage ( ValidationError , "<STR_LIT>" ) : <EOL> f . clean ( None ) <EOL> self . assertTrue ( f . clean ( True ) ) <EOL> with self . assertRaisesMessage ( ValidationError , "<STR_LIT>" ) : <EOL> f . clean ( False ) <EOL> self . assertTrue ( f . clean ( <NUM_LIT:1> ) ) <EOL> with self . assertRaisesMessage ( ValidationError , "<STR_LIT>" ) : <EOL> f . clean ( <NUM_LIT:0> ) <EOL> self . assertTrue ( f . clean ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( f . clean ( '<STR_LIT:True>' ) ) <EOL> with self . assertRaisesMessage ( ValidationError , "<STR_LIT>" ) : <EOL> f . clean ( '<STR_LIT:False>' ) <EOL> def test_booleanfield_clean_2 ( self ) : <EOL> f = BooleanField ( required = False ) <EOL> self . assertEqual ( False , f . clean ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( False , f . clean ( None ) ) <EOL> self . assertEqual ( True , f . clean ( True ) ) <EOL> self . assertEqual ( False , f . clean ( False ) ) <EOL> self . assertEqual ( True , f . clean ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( False , f . clean ( <NUM_LIT:0> ) ) <EOL> self . assertEqual ( True , f . clean ( '<STR_LIT:1>' ) ) <EOL> self . assertEqual ( False , f . clean ( '<STR_LIT:0>' ) ) <EOL> self . assertEqual ( True , f . clean ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( False , f . clean ( '<STR_LIT:False>' ) ) <EOL> self . assertEqual ( False , f . clean ( '<STR_LIT:false>' ) ) <EOL> self . assertEqual ( False , f . clean ( '<STR_LIT>' ) ) <EOL> def test_boolean_picklable ( self ) : <EOL> self . assertIsInstance ( pickle . loads ( pickle . dumps ( BooleanField ( ) ) ) , BooleanField ) <EOL> def test_booleanfield_changed ( self ) : <EOL> f = BooleanField ( ) <EOL> self . assertFalse ( f . has_changed ( None , None ) ) <EOL> self . assertFalse ( f . has_changed ( None , '<STR_LIT>' ) ) <EOL> self . assertFalse ( f . has_changed ( '<STR_LIT>' , None ) ) <EOL> self . assertFalse ( f . has_changed ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertTrue ( f . has_changed ( False , '<STR_LIT>' ) ) <EOL> self . assertFalse ( f . has_changed ( True , '<STR_LIT>' ) ) <EOL> self . assertTrue ( f . has_changed ( True , '<STR_LIT>' ) ) <EOL> self . assertTrue ( f . has_changed ( '<STR_LIT:False>' , '<STR_LIT>' ) ) <EOL> self . assertFalse ( f . has_changed ( False , '<STR_LIT:False>' ) ) <EOL> self . assertFalse ( f . has_changed ( True , '<STR_LIT:True>' ) ) <EOL> self . assertTrue ( f . has_changed ( False , '<STR_LIT:True>' ) ) <EOL> self . assertTrue ( f . has_changed ( True , '<STR_LIT:False>' ) ) </s>
