code: def expect_deprecation(function_name: str):
      """
      Decorator to flag tests that we expect to use deprecated arguments.
  
      Args:
          function_name (`str`):
              Name of the function that we expect to use in a deprecated way.
  
      NOTE: if a test is expected to warns FutureWarnings but is not, the test will fail.
  
      Context: over time, some arguments/methods become deprecated. In order to track
               deprecation in tests, we run pytest with flag `-Werror::FutureWarning`.
               In order to keep old tests during the deprecation phase (before removing
               the feature completely) without changing them internally, we can flag
               them with this decorator.
      See full discussion in https://github.com/huggingface/huggingface_hub/pull/952.
  
      This decorator works hand-in-hand with the `_deprecate_arguments` and
      `_deprecate_positional_args` decorators.
  
      Example
      ```py
      # in src/hub_mixins.py
      from .utils._deprecation import _deprecate_arguments
  
      @_deprecate_arguments(version="0.12", deprecated_args={"repo_url"})
      def push_to_hub(...):
          (...)
  
      # in tests/test_something.py
      from .testing_utils import expect_deprecation
  
      class SomethingTest(unittest.TestCase):
          (...)
  
          @expect_deprecation("push_to_hub"):
          def test_push_to_hub_git_version(self):
              (...)
              push_to_hub(repo_url="something") <- Should warn with FutureWarnings
              (...)
      ```
      """
  
      def _inner_decorator(test_function: Callable) -> Callable:
          @wraps(test_function)
          def _inner_test_function(*args, **kwargs):
              with pytest.warns(
                  FutureWarning, match=f".*'{function_name}'.*"
              ):
                  return test_function(*args, **kwargs)
  
          return _inner_test_function
  
      return _inner_decorator
  
imports: import inspect
  import os
  import shutil
  import stat
  import time
  import unittest
  import uuid
  from contextlib import contextmanager
  from enum import Enum
  from functools import wraps
  from pathlib import Path
  from typing import Callable, Optional, Type, TypeVar, Union
  from unittest.mock import Mock, patch
  import pytest
  import requests
  from huggingface_hub.utils import is_gradio_available, logging, reset_sessions
  from tests.testing_constants import ENDPOINT_PRODUCTION, ENDPOINT_PRODUCTION_URL_SCHEME
label_desc: Use image node_id 10 for calling a global function with example usage: expect_deprecation(function_name) and returns: _inner_decorator, _inner_test_function, test_function