code: def test_deprecated_and_legacy(msg, func, klass):
      """Test deprecated and legacy decorators."""
      if msg == "deprecated":
          with pytest.warns(FutureWarning, match=f"{msg} class"):
              _klass = klass()
          with pytest.warns(FutureWarning, match=f"{msg} method"):
              _klass.bad()
          with pytest.warns(FutureWarning, match=f"{msg} func"):
              func()
      else:
          with catch_logging(verbose="info") as log:
              _klass = klass()
              _klass.bad()
              func()
          log = log.getvalue()
          for kind in ("class", "method", "func"):
              assert f"New code should use replacement_{kind}" in log
      assert msg.upper() in klass.__init__.__doc__
      assert msg.upper() in klass.bad.__doc__
      assert msg.upper() in _klass.bad.__doc__
      assert msg.upper() in func.__doc__
  
imports: import webbrowser
  import pytest
  from mne import grade_to_tris, open_docs
  from mne.utils import catch_logging, copy_doc, copy_function_doc_to_method_doc, deprecated, deprecated_alias, legacy, linkcode_resolve
label_desc: Use image node_id 5 for calling a global function with example usage: test_deprecated_and_legacy(msg, func, klass) without return types