code: def format_message(msg):
      
      callerframerecord = inspect.stack()[2]
      frame = callerframerecord[0]
      info = inspect.getframeinfo(frame)
      _, filename = os.path.split(info.filename)
      caller_site = "In file {!s}, in function {!s}, at line {:d}".format(filename,
                                                                          info.function,
                                                                          info.lineno)
      return "{!s}\n{!s}\n{!s}".format(msg, caller_site, info.code_context)
docs: Formatting function for assert messages. Fetches the filename,
      function and line number of the code causing the fail
      and formats it into a three-line error message. Stack inspection is used to get the information.
      Originally done by BLE-team for their testcases.
  
      :param msg: Message to be printed along with the information.
      :return: Formatted message as string.