#NEWLINE# @ patch ( 'orchestra.utils.time_tracking._reset_timer' , side_effect = Exception ) #NEWLINE# def test_stop_timer_atomic( self , mock_reset ) : #NEWLINE# #INDENT# timer = TaskTimer ( worker = self . worker , start_time = self . time ) #NEWLINE# timer . save ( ) #NEWLINE# time_entries_count = TimeEntry . objects . count ( ) #NEWLINE# self . assertIsNone ( timer . stop_time ) #NEWLINE# with self . assertRaises ( Exception ) : #NEWLINE# #INDENT# stop_timer ( self . worker ) #NEWLINE# #UNINDENT# timer . refresh_from_db ( ) #NEWLINE# self . assertIsNone ( timer . stop_time ) #NEWLINE# self . assertEqual ( TimeEntry . objects . count ( ) , time_entries_count )