<s> import unittest <EOL> class NoneDeref ( object ) : <EOL> def __getattr__ ( self , attr ) : <EOL> return self <EOL> def __getstate__ ( self ) : <EOL> return None <EOL> def __setstate__ ( self , state ) : <EOL> pass <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:None>" <EOL> def __nonzero__ ( self ) : <EOL> return False <EOL> def __bool__ ( self ) : <EOL> return False <EOL> class NoneDerefTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . object = NoneDeref ( ) <EOL> def test_any_attribute_is_present_and_falsy ( self ) : <EOL> self . assertFalse ( self . object . foo ) <EOL> self . assertFalse ( self . object . bar ) <EOL> def test_object_is_falsy ( self ) : <EOL> self . assertFalse ( self . object ) <EOL> def test_object_can_be_pickled ( self ) : <EOL> import pickle <EOL> s = pickle . dumps ( self . object ) <EOL> n = pickle . loads ( s ) <EOL> self . assertFalse ( n ) <EOL> self . assertFalse ( self . object . foo ) <EOL> self . assertFalse ( self . object . bar ) <EOL> def test_object_converts_to_None_string ( self ) : <EOL> self . assertEqual ( str ( self . object ) , "<STR_LIT:None>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
