class_docstr: Tests for verifying that SimplePipelineEngine calls hooks as expected.
      
class_docstr_tok: ["Tests","for","verifying","that","SimplePipelineEngine","calls","hooks","as","expected","."]
code: def test_engine_calls_hooks(self, nhooks, chunked):
      # Pass multiple hooks to make sure we call methods on all of them.
      hooks = [TestingHooks() for _ in range(nhooks)]
  
      pipeline = Pipeline(
          {
              "bool_": TestingDataSet.bool_col.latest,
              "factor_rank": TrivialFactor().rank().zscore(),
          },
          domain=US_EQUITIES,
      )
      start_date, end_date = self.trading_days[[-10, -1]]
  
      if chunked:
          self.run_chunked_pipeline(
              pipeline=pipeline,
              start_date=start_date,
              end_date=end_date,
              chunksize=5,
              hooks=hooks,
          )
          expected_chunks = [
              tuple(self.trading_days[[-10, -6]]),
              tuple(self.trading_days[[-5, -1]]),
          ]
      else:
          self.run_pipeline(
              pipeline=pipeline,
              start_date=start_date,
              end_date=end_date,
              hooks=hooks,
          )
          expected_chunks = [(start_date, end_date)]
  
      expected_loads = set(TrivialFactor.inputs) | {
          TestingDataSet.bool_col
      }
      expected_computes = {
          TestingDataSet.bool_col.latest,
          TrivialFactor(),
          TrivialFactor().rank(),
          TrivialFactor().rank().zscore(),
          Everything(),  # Default input for .rank().
      }
  
      for h in hooks + [self.global_testing_hook]:
          self.verify_trace(
              h.trace,
              pipeline,
              pipeline_start_date=start_date,
              pipeline_end_date=end_date,
              expected_loads=expected_loads,
              expected_computes=expected_computes,
              expected_chunks=expected_chunks,
          )
  
imports: import itertools
  from operator import attrgetter
  import numpy
  import pandas
  import toolz
  from zipline.pipeline import Pipeline
  from zipline.pipeline.classifiers import Everything
  from zipline.pipeline.domain import US_EQUITIES
  from zipline.pipeline.factors import CustomFactor
  from zipline.pipeline.data import Column, DataSet
  from zipline.pipeline.data.testing import TestingDataSet
  from zipline.pipeline.hooks.testing import TestingHooks
  from zipline.pipeline.hooks.progress import ProgressHooks, repr_htmlsafe, TestingProgressPublisher
  from zipline.pipeline.term import AssetExists, ComputableTerm, LoadableTerm
  from zipline.testing import parameter_space
  from zipline.testing.fixtures import ZiplineTestCase, WithSeededRandomPipelineEngine
  from zipline.testing.predicates import assert_almost_equal, instance_of
label_desc: Use image node_id 3 for calling the HooksTestCase obj's underlying member method code with example usage: obj.test_engine_calls_hooks(nhooks, chunked) without return types