#NEWLINE# def start( self ) : #NEWLINE# #INDENT# if self . tick : #NEWLINE# #INDENT# time_to_freeze = TickingDateTimeFactory ( self . time_to_freeze , real_datetime . now ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time_to_freeze = FrozenDateTimeFactory ( self . time_to_freeze ) #NEWLINE# #UNINDENT# datetime . datetime = FakeDatetime #NEWLINE# datetime . date = FakeDate #NEWLINE# fake_time = FakeTime ( time_to_freeze , time . time ) #NEWLINE# fake_localtime = FakeLocalTime ( time_to_freeze , time . localtime ) #NEWLINE# fake_gmtime = FakeGMTTime ( time_to_freeze , time . gmtime ) #NEWLINE# fake_strftime = FakeStrfTime ( time_to_freeze , time . strftime ) #NEWLINE# time . time = fake_time #NEWLINE# time . localtime = fake_localtime #NEWLINE# time . gmtime = fake_gmtime #NEWLINE# time . strftime = fake_strftime #NEWLINE# copyreg . dispatch_table [ real_datetime ] = pickle_fake_datetime #NEWLINE# copyreg . dispatch_table [ real_date ] = pickle_fake_date #NEWLINE# to_patch = [ ( 'real_date' , real_date , 'FakeDate' , FakeDate ) , ( 'real_datetime' , real_datetime , 'FakeDatetime' , FakeDatetime ) , ( 'real_gmtime' , real_gmtime , 'FakeGMTTime' , fake_gmtime ) , ( 'real_localtime' , real_localtime , 'FakeLocalTime' , fake_localtime ) , ( 'real_strftime' , real_strftime , 'FakeStrfTime' , fake_strftime ) , ( 'real_time' , real_time , 'FakeTime' , fake_time ) ] #NEWLINE# real_names = tuple ( ( real_name for ( real_name , real , fake_name , fake ) in to_patch ) ) #NEWLINE# self . fake_names = tuple ( ( fake_name for ( real_name , real , fake_name , fake ) in to_patch ) ) #NEWLINE# self . reals = dict ( ( ( id ( fake ) , real ) for ( real_name , real , fake_name , fake ) in to_patch ) ) #NEWLINE# fakes = dict ( ( ( id ( real ) , fake ) for ( real_name , real , fake_name , fake ) in to_patch ) ) #NEWLINE# add_change = self . undo_changes . append #NEWLINE# self . modules_at_start = set ( sys . modules . keys ( ) ) #NEWLINE# for ( mod_name , module ) in list ( sys . modules . items ( ) ) : #NEWLINE# #INDENT# if ( ( mod_name is None ) or ( module is None ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if mod_name . startswith ( self . ignore ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not hasattr ( module , '__name__' ) ) or ( module . __name__ in ( 'datetime' , 'time' ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for module_attribute in dir ( module ) : #NEWLINE# #INDENT# if ( module_attribute in real_names ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# attribute_value = getattr ( module , module_attribute ) #NEWLINE# #UNINDENT# except ( ImportError , AttributeError , TypeError ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# fake = fakes . get ( id ( attribute_value ) ) #NEWLINE# if fake : #NEWLINE# #INDENT# setattr ( module , module_attribute , fake ) #NEWLINE# add_change ( ( module , module_attribute , attribute_value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# datetime . datetime . times_to_freeze . append ( time_to_freeze ) #NEWLINE# datetime . datetime . tz_offsets . append ( self . tz_offset ) #NEWLINE# datetime . date . dates_to_freeze . append ( time_to_freeze ) #NEWLINE# datetime . date . tz_offsets . append ( self . tz_offset ) #NEWLINE# return time_to_freeze