class_docstr: TestResult contains information useful for tracking test results
class_docstr_tok: ["TestResult","contains","information","useful","for","tracking","test","results"]
code: def __str__(self):
      fmt = {
          "header": "Test #{idx:02d}".format(idx=self._index + 1),
      }
  
      if self.error:
          fmt["error"] = format_red("Error - {}".format(self.error))
          return self._ERROR_TEMPLATE.format(**fmt)
  
      if self.passed and not self._verbose:
          # Simply render "Test #XYZ: Pass" if the whole test case passed
          fmt["pass"] = self._PASS_STRING
          return self._PASS_TEMPLATE.format(**fmt)
  
      # Otherwise, expand the entire test with verbose details
      template = self._SIMPLE_TEMPLATE + "\n" + self._DESCRIPTION_LINE
      fmt["description"] = self.description
  
      # First, render classification
      template += "\n" + self._CLASSIFICATION_STATUS_TEMPLATE
      fmt["classification_status"] = (
          self._PASS_STRING
          if self.classification_tests_passed
          else self._FAIL_STRING
      )
      fmt["expected_type"] = self.log
      fmt["classified_type"] = (
          self._classified_result.log_schema_type
          if self._classified
          else format_red(
              self._classified_result.log_schema_type
              if self
              else self._NONE_STRING
          )
      )
  
      # If it was classification-only, note it down
      if self.classify_only:
          template += self._CLASSIFY_ONLY
  
      # Render the result of rules engine run
      if self.rule_tests_were_run:
          template += "\n" + self._RULES_STATUS_TEMPLATE
          fmt["rules_status"] = (
              self._PASS_STRING
              if self.rule_tests_passed
              else self._FAIL_STRING
          )
          fmt["triggered_rules"] = self._format_rules(
              self._triggered_rules, self.expected_rules
          )
  
          fmt["expected_rules"] = self._format_rules(
              self.expected_rules, self._triggered_rules
          )
  
          disabled = self._disabled_rules
          if disabled:
              template += self._DISABLED_RULES_TEMPLATE
              fmt["disabled_rules"] = ", ".join(disabled)
  
          # Render live test results
          if self.has_live_tests:
              template += self._ALERTS_TEMPLATE
              (
                  fmt["sent_alerts"],
                  fmt["failed_alerts"],
              ) = self._format_alert_results()
  
      # Render any publisher errors
      if self.publisher_tests_were_run:
          template += "\n" + self._PUBLISHERS_STATUS_TEMPLATE
  
          num_pass = 0
          num_total = 0
          for num_total, result in enumerate(
              self._publication_results, start=1
          ):
              num_pass += 1 if result["success"] else 0
  
          fmt["publishers_status"] = (
              format_green("{}/{} Passed".format(num_pass, num_total))
              if num_pass == num_total
              else format_red(
                  "{}/{} Passed".format(num_pass, num_total)
              )
          )
          pad = " " * self._DEFAULT_INDENT * 3
          fmt["publisher_errors"] = (
              format_red(
                  "\n".join(
                      [
                          "{}{}".format(pad, error)
                          for error in self.publisher_errors
                      ]
                  )
              )
              if self.publisher_errors
              else "{}{}".format(pad, self._NONE_STRING)
          )
  
      return textwrap.dedent(template.format(**fmt)).rstrip() + "\n"
  
imports: from collections import defaultdict
  import textwrap
  from streamalert.shared import rule
  from streamalert.shared.logger import get_logger
  from streamalert_cli.test.event import TestEvent
  from streamalert_cli.test.format import format_green, format_red, format_underline
label_desc: Use image node_id 3 for calling the TestResult obj's underlying member method code with example usage: obj.__str__() and returns: unknown, self, self