class_docstr: Test deprecator function specified in ``dep_func``
class_docstr_tok: ["Test","deprecator","function","specified","in","``","dep_func","``"]
code: def test_dep_func(self):
      # Test function deprecation
      dec = self.dep_func
      func = dec("foo")(func_no_doc)
      with pytest.deprecated_call():
          assert func() is None
      assert func.__doc__ == "foo\n"
      func = dec("foo")(func_doc)
      with pytest.deprecated_call() as w:
          assert func(1) is None
          assert len(w) == 1
      assert func.__doc__ == "A docstring\n\nfoo\n"
      func = dec("foo")(func_doc_long)
      with pytest.deprecated_call() as w:
          assert func(1, 2) is None
          assert len(w) == 1
      assert (
          func.__doc__
          == f'A docstring\n   \n   foo\n   \n{indent(TESTSETUP, "   ", lambda x: True)}'
          f'   Some text\n{indent(TESTCLEANUP, "   ", lambda x: True)}'
      )
  
      # Try some since and until versions
      func = dec("foo", "1.1")(func_no_doc)
      assert func.__doc__ == "foo\n\n* deprecated from version: 1.1\n"
      with pytest.deprecated_call() as w:
          assert func() is None
          assert len(w) == 1
      func = dec("foo", until="99.4")(func_no_doc)
      with pytest.deprecated_call() as w:
          assert func() is None
          assert len(w) == 1
      assert (
          func.__doc__
          == f"foo\n\n* Will raise {ExpiredDeprecationError} as of version: 99.4\n"
      )
      func = dec("foo", until="1.8")(func_no_doc)
      with pytest.raises(ExpiredDeprecationError):
          func()
      assert (
          func.__doc__
          == f"foo\n\n* Raises {ExpiredDeprecationError} as of version: 1.8\n"
      )
      func = dec("foo", "1.2", "1.8")(func_no_doc)
      with pytest.raises(ExpiredDeprecationError):
          func()
      assert (
          func.__doc__
          == "foo\n\n* deprecated from version: 1.2\n* Raises "
          f"{ExpiredDeprecationError} as of version: 1.8\n"
      )
      func = dec("foo", "1.2", "1.8")(func_doc_long)
      assert (
          func.__doc__
          == f"""\
  A docstring
  
  foo
  
  * deprecated from version: 1.2
  * Raises {ExpiredDeprecationError} as of version: 1.8
  """
      )
      with pytest.raises(ExpiredDeprecationError):
          func()
  
      # Check different warnings and errors
      func = dec("foo", warn_class=UserWarning)(func_no_doc)
      with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
          warnings.simplefilter("always")
          assert func() is None
          assert len(w) == 1
          assert w[0].category is UserWarning
  
      func = dec("foo", error_class=CustomError)(func_no_doc)
      with pytest.deprecated_call():
          assert func() is None
  
      func = dec("foo", until="1.8", error_class=CustomError)(
          func_no_doc
      )
      with pytest.raises(CustomError):
          func()
  
file_path: nibabel/nibabel/tests/test_deprecator.py
imports: import sys
  import warnings
  from functools import partial
  from textwrap import indent
  import pytest
  from nibabel.deprecator import TESTCLEANUP, TESTSETUP, Deprecator, ExpiredDeprecationError, _add_dep_doc, _ensure_cr
  from ..testing import clear_and_catch_warnings
label_desc: Use image node_id 1 for calling the TestDeprecatorFunc obj's underlying member method code with example usage: obj.test_dep_func() without return types