code: def test_iterator_stop_on_chunksize(all_parsers):
      # gh-3967: stopping iteration when chunksize is specified
      parser = all_parsers
      data = """A,B,C
  foo,1,2,3
  bar,4,5,6
  baz,7,8,9
  """
      if parser.engine == "pyarrow":
          msg = "The 'chunksize' option is not supported with the 'pyarrow' engine"
          with pytest.raises(ValueError, match=msg):
              parser.read_csv(StringIO(data), chunksize=1)
          return
  
      with parser.read_csv(StringIO(data), chunksize=1) as reader:
          result = list(reader)
  
      assert len(result) == 3
      expected = DataFrame(
          [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
          index=["foo", "bar", "baz"],
          columns=["A", "B", "C"],
      )
      tm.assert_frame_equal(concat(result), expected)
  
file_path: pandas/pandas/tests/io/parser/common/test_iterator.py
imports: from io import StringIO
  import pytest
  from pandas import DataFrame, concat
  import pandas._testing
label_desc: Use image node_id 3 for calling a global function with example usage: test_iterator_stop_on_chunksize(all_parsers) without return types