code: def test_schema_to_string_with_metadata():
      lorem = """\
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan vel
  turpis et mollis. Aliquam tincidunt arcu id tortor blandit blandit. Donec
  eget leo quis lectus scelerisque varius. Class aptent taciti sociosqu ad
  litora torquent per conubia nostra, per inceptos himenaeos. Praesent
  faucibus, diam eu volutpat iaculis, tellus est porta ligula, a efficitur
  turpis nulla facilisis quam. Aliquam vitae lorem erat. Proin a dolor ac libero
  dignissim mollis vitae eu mauris. Quisque posuere tellus vitae massa
  pellentesque sagittis. Aenean feugiat, diam ac dignissim fermentum, lorem
  sapien commodo massa, vel volutpat orci nisi eu justo. Nulla non blandit
  sapien. Quisque pretium vestibulum urna eu vehicula."""
      # ARROW-7063
      my_schema = pa.schema(
          [
              pa.field(
                  "foo", "int32", False, metadata={"key1": "value1"}
              ),
              pa.field(
                  "bar", "string", True, metadata={"key3": "value3"}
              ),
          ],
          metadata={"lorem": lorem},
      )
  
      assert (
          my_schema.to_string()
          == """\
  foo: int32 not null
    -- field metadata --
    key1: 'value1'
  bar: string
    -- field metadata --
    key3: 'value3'
  -- schema metadata --
  lorem: '"""
          + lorem[:65]
          + "' + "
          + str(len(lorem) - 65)
      )
  
      # Metadata that exactly fits
      result = pa.schema(
          [("f0", "int32")], metadata={"key": "value" + "x" * 62}
      ).to_string()
      assert (
          result
          == """\
  f0: int32
  -- schema metadata --
  key: 'valuexxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'"""
      )
  
      assert (
          my_schema.to_string(truncate_metadata=False)
          == """\
  foo: int32 not null
    -- field metadata --
    key1: 'value1'
  bar: string
    -- field metadata --
    key3: 'value3'
  -- schema metadata --
  lorem: '{}'""".format(
              lorem
          )
      )
  
      assert (
          my_schema.to_string(
              truncate_metadata=False, show_field_metadata=False
          )
          == """\
  foo: int32 not null
  bar: string
  -- schema metadata --
  lorem: '{}'""".format(
              lorem
          )
      )
  
      assert (
          my_schema.to_string(
              truncate_metadata=False, show_schema_metadata=False
          )
          == """\
  foo: int32 not null
    -- field metadata --
    key1: 'value1'
  bar: string
    -- field metadata --
    key3: 'value3'"""
      )
  
      assert (
          my_schema.to_string(
              truncate_metadata=False,
              show_field_metadata=False,
              show_schema_metadata=False,
          )
          == """\
  foo: int32 not null
  bar: string"""
      )
  
imports: from collections import OrderedDict
  import sys
  import weakref
  import pytest
  import numpy
  import pyarrow
  import pyarrow.tests.util
  from pyarrow.vendored.version import Version
label_desc: Use image node_id 14 for calling a global function with example usage: test_schema_to_string_with_metadata() without return types