code: def provide_metadata(fn, *args, **kw):
      """Provide bound MetaData for a single test, dropping afterwards.
  
      Legacy; use the "metadata" pytest fixture.
  
      """
  
      from . import fixtures
  
      metadata = schema.MetaData()
      self = args[0]
      prev_meta = getattr(self, "metadata", None)
      self.metadata = metadata
      try:
          return fn(*args, **kw)
      finally:
          # close out some things that get in the way of dropping tables.
          # when using the "metadata" fixture, there is a set ordering
          # of things that makes sure things are cleaned up in order, however
          # the simple "decorator" nature of this legacy function means
          # we have to hardcode some of that cleanup ahead of time.
  
          # close ORM sessions
          fixtures.close_all_sessions()
  
          # integrate with the "connection" fixture as there are many
          # tests where it is used along with provide_metadata
          cfc = fixtures.base._connection_fixture_connection
          if cfc:
              # TODO: this warning can be used to find all the places
              # this is used with connection fixture
              # warn("mixing legacy provide metadata with connection fixture")
              drop_all_tables_from_metadata(metadata, cfc)
              # as the provide_metadata fixture is often used with "testing.db",
              # when we do the drop we have to commit the transaction so that
              # the DB is actually updated as the CREATE would have been
              # committed
              cfc.get_transaction().commit()
          else:
              drop_all_tables_from_metadata(metadata, config.db)
          self.metadata = prev_meta
  
imports: from __future__ import annotations
  from collections import deque
  import decimal
  import gc
  from itertools import chain
  import random
  import sys
  from sys import getsizeof
  import types
  from .None import config
  from .None import mock
  from ..None import inspect
  from ..engine import Connection
  from ..schema import Column
  from ..schema import DropConstraint
  from ..schema import DropTable
  from ..schema import ForeignKeyConstraint
  from ..schema import MetaData
  from ..schema import Table
  from ..sql import schema
  from ..sql.sqltypes import Integer
  from ..util import decorator
  from ..util import defaultdict
  from ..util import has_refcount_gc
  from ..util import inspect_getfullargspec
label_desc: Use image node_id 10 for calling a global function with example usage: provide_metadata(fn) and returns: fn