def testFindIndexOfDefiningFrameForOpReturnsZeroOnError(self): with ops.Graph().as_default(): local_op = constant_op.constant(43).op # Ensure all frames look like TF frames. modified_tb = _modify_op_stack_with_filenames( local_op.traceback[:7], # Truncate stack to known length. num_user_frames=0, user_filename="user_file.py", num_inner_tf_frames=7) idx = error_interpolation._find_index_of_defining_frame( modified_tb) self.assertEqual(0, idx)
def testFindIndexOfDefiningFrameForOp(self): local_op = constant_op.constant(42).op user_filename = "hope.py" _modify_op_stack_with_filenames(local_op, num_user_frames=3, user_filename=user_filename, num_inner_tf_frames=5) idx = error_interpolation._find_index_of_defining_frame( local_op._traceback) # Expected frame is 6th from the end because there are 5 inner frames witih # TF filenames. expected_frame = len(local_op._traceback) - 6 self.assertEqual(expected_frame, idx)