def test_it_ignores_attribute_error_on_notification(self): # Arrange call_handler = Mock() call_handler.on_call.side_effect = AttributeError call_handler.on_return.side_effect = AttributeError thread_scoped_tracer = ThreadScopedTracer(call_handler) # Act thread_scoped_tracer.start() function1() thread_scoped_tracer.stop()
def test_it_notifies_the_return_from_a_function(self): # Arrange call_handler = Mock() thread_scoped_tracer = ThreadScopedTracer(call_handler) thread_scoped_tracer.start() function1() thread_scoped_tracer.stop() assert_equal(call_handler.on_return.call_count, 1) thread_digest = call_handler.on_return.call_args_list[0][0][0] actual_function_name = thread_digest.function_name assert_equal(actual_function_name, 'function1')
def test_it_notifies_one_function_call(self): # Arrange call_handler = Mock() thread_scoped_tracer = ThreadScopedTracer(call_handler) # Act thread_scoped_tracer.start() function1() thread_scoped_tracer.stop() # Assert assert_equal(call_handler.on_call.call_count, 1) actual_thread_digest = call_handler.on_call.call_args_list[0][0][0] actual_function_name = actual_thread_digest.function_name assert_equal(actual_function_name, 'function1')
def test_it_notifies_two_function_calls(self): # Arrange call_handler = Mock() thread_scoped_tracer = ThreadScopedTracer(call_handler) # Act thread_scoped_tracer.start() function1() function2(1) thread_scoped_tracer.stop() # Assert assert_equal(call_handler.on_call.call_count, 2) actual_thread_digest1 = call_handler.on_call.call_args_list[0][0][0] actual_function_name1 = actual_thread_digest1.function_name assert_equal(actual_function_name1, 'function1') thread_digest2 = call_handler.on_call.call_args_list[1][0][0] actual_function_name2 = thread_digest2.function_name assert_equal(actual_function_name2, 'function2')