code: def test_info_max_cols():
      df = DataFrame(np.random.default_rng(2).standard_normal((10, 5)))
      for len_, verbose in [(5, None), (5, False), (12, True)]:
          # For verbose always      ^ setting  ^ summarize ^ full output
          with option_context("max_info_columns", 4):
              buf = StringIO()
              df.info(buf=buf, verbose=verbose)
              res = buf.getvalue()
              assert len(res.strip().split("\n")) == len_
  
      for len_, verbose in [(12, None), (5, False), (12, True)]:
          # max_cols not exceeded
          with option_context("max_info_columns", 5):
              buf = StringIO()
              df.info(buf=buf, verbose=verbose)
              res = buf.getvalue()
              assert len(res.strip().split("\n")) == len_
  
      for len_, max_cols in [(12, 5), (5, 4)]:
          # setting truncates
          with option_context("max_info_columns", 4):
              buf = StringIO()
              df.info(buf=buf, max_cols=max_cols)
              res = buf.getvalue()
              assert len(res.strip().split("\n")) == len_
  
          # setting wouldn't truncate
          with option_context("max_info_columns", 5):
              buf = StringIO()
              df.info(buf=buf, max_cols=max_cols)
              res = buf.getvalue()
              assert len(res.strip().split("\n")) == len_
  
imports: from io import StringIO
  import re
  from string import ascii_uppercase
  import sys
  import textwrap
  import numpy
  import pytest
  from pandas.compat import IS64, PYPY
  from pandas import CategoricalIndex, DataFrame, MultiIndex, Series, date_range, option_context
  import pandas._testing
label_desc: Use image node_id 13 for calling a global function with example usage: test_info_max_cols() without return types