code: def report_failures(error=False, display=True, clear=True):
      
          
      global _failed_expectations
  
      output = []
  
      # Copy as failures are returned 
      all_failed_expectations = _failed_expectations[:]
  
      if all_failed_expectations:
  
          output.append('\nFailed Expectations: %s\n\n' % len(all_failed_expectations))
  
          for i, failure in enumerate(all_failed_expectations, start=1):
  
              report_line = '{idx}: File {file}, line {line}, in {funcname}()\n    "{expression}" is not True\n'
  
              if failure['msg']:
                  report_line += '        -- {msg}\n'
  
              report_line += '\n'
  
              failure['idx'] = i
              output.append(report_line.format(**failure))
  
          if clear:
              _failed_expectations = []
      else:
          output.append("All expectations met.")
  
      if error:
          raise FailedValidationError("\n" + ''.join(output))
      elif display:
          print(''.join(output))
      
      if all_failed_expectations:
          return (''.join(output), all_failed_expectations)
      else:
          return None
docs: Print details of logged failures in expect function
  
      If no failures are detected, None is returned by the function.
  
      Parameters
      ----------
      error:bool
          If true, will raise an Expectation of type 'FaliedValidationError' instead of printing to console
      display: bool
          If True, will print the failure report to console as well as returning it as a string. If 
          error = True do nothing.
      clear: bool
          If True, all logged failured will be cleared after being reported. 
  
      Returns
      -------
      string 
          The string formated failure report.
      list of dict
          The failed expectations. Each dictionary contains the keys:
              idx - the number of the failed expectation in the list starting at one, 
              expression - Code that is evaluated
              file - the file name where the validation function was defined, 
              funcname - the name of the validation function, 
              line - the line of the validation function that the expression was on
              msg - the error message associated with the expression, if there was one.