class_docstr: TestRunner to handle running various tests
docstr: Process an individual test file
docstr_tok: ["Process","an","individual","test","file"]
code: def _process_test_file(self, test_file_path):
      """Process an individual test file"""
      # Iterate over the individual test events in the file
      event_file = TestEventFile(test_file_path)
      for event in event_file.process_file(
          self._config, self._verbose, self._testing_rules
      ):
          # Each test event should be tied to a cluster, via the configured data_sources
          # Reset the CLUSTER env var for each test, since it could differ between each event
          # This env var is used from within the classifier to load the proper cluster config
          if "CLUSTER" in os.environ:
              del os.environ["CLUSTER"]
  
          for cluster_name, cluster_value in self._config[
              "clusters"
          ].items():
              if event.service not in cluster_value["data_sources"]:
                  LOGGER.debug(
                      'Cluster "%s" does not have service "%s" configured as a data source',
                      cluster_name,
                      event.service,
                  )
                  continue
  
              sources = set(
                  cluster_value["data_sources"][event.service]
              )
              if event.source not in sources:
                  LOGGER.debug(
                      'Cluster "%s" does not have the source "%s" configured as a data source '
                      'for service "%s"',
                      cluster_name,
                      event.source,
                      event.service,
                  )
                  continue
  
              # If we got here, then this cluster is actually configured for this data source
              os.environ["CLUSTER"] = cluster_name
              break
  
          # A misconfigured test event and/or cluster config can cause this to be unset
          if "CLUSTER" not in os.environ:
              error = (
                  'Test event\'s "service" ({}) and "source" ({}) are not defined within '
                  'the "data_sources" of any configured clusters: {}:{}'
              ).format(
                  event.service,
                  event.source,
                  event_file.path,
                  event.index,
              )
              raise ConfigError(error)
  
          classifier_result = self._run_classification(event.record)
  
          event.set_classified_result(classifier_result)
          if not event:
              continue
  
          # Ensure this event actually contains any specific rules, if filtering is being used
          if not event.check_for_rules(self._rules):
              continue
  
          if event.classify_only:
              continue  # Do not run rules on events that are only for validation
  
          self._tested_rules.update(event.expected_rules)
  
          if self._type in {self.Types.RULES, self.Types.LIVE}:
              event.alerts = self._run_rules_engine(
                  event.classified_log.sqs_messages
              )
  
              if event.publisher_tests:
                  runner = PublisherTestRunner()
                  runner.run_publisher_tests(event)
  
              if self._type == self.Types.LIVE:
                  for alert in event.alerts:
                      alert_result = self._run_alerting(alert)
                      event.add_live_test_result(
                          alert.rule_name, alert_result
                      )
  
      self._passed += event_file.passed
      self._failed += event_file.failed
  
      # It is possible for a test_event to have no results, but contain errors
      # so only print it if it does and if quiet mode is not being used
      # Quite mode is overridden if not all of the events passed
      if event_file.error or not (
          self._quiet and event_file.all_passed
      ):
          if event_file.should_print:
              print(event_file)
  
imports: import argparse
  import os
  import jmespath
  from mock import patch, MagicMock
  from streamalert.alert_processor import main
  from streamalert.alert_processor.helpers import compose_alert
  from streamalert.alert_processor.outputs.output_base import OutputDispatcher
  from streamalert.classifier import classifier
  from streamalert.rules_engine import rules_engine
  from streamalert.shared import rule
  from streamalert.shared.config import ConfigError
  from streamalert.shared.logger import get_logger
  from streamalert.shared.stats import RuleStatisticTracker
  from streamalert_cli.helpers import check_credentials
  from streamalert_cli.test.format import format_green, format_red, format_underline, format_yellow
  from streamalert_cli.test.mocks import LookupTableMocks, ThreatIntelMocks
  from streamalert_cli.test.event_file import TestEventFile
  from streamalert_cli.utils import CLICommand, DirectoryType, generate_subparser, UniqueSortedFileListAction, UniqueSortedListAction
label_desc: Use image node_id 11 for calling the TestRunner obj's underlying member method code with example usage: obj._process_test_file(test_file_path) without return types