code: def _count_relevant_tb_levels(tb):
      
      length = contiguous_unittest_frames = 0
      while tb:
          length += 1
          if _is_unittest_frame(tb):
              contiguous_unittest_frames += 1
          else:
              contiguous_unittest_frames = 0
          tb = tb.tb_next
      return length - contiguous_unittest_frames
docs: Return the number of frames in ``tb`` before all that's left is unittest frames.
  
      Unlike its namesake in unittest, this doesn't bail out as soon as it hits a
      unittest frame, which means we don't bail out as soon as somebody uses the
      mock library, which defines ``__unittest``.