code: def test_deprecation():
      with warnings.catch_warnings(record=True) as w:
          warnings.filterwarnings("always", "", UserWarning)
  
          class DeprecationSpec1(nib.TraitedSpec):
              foo = nib.traits.Int(deprecated="0.1")
  
          spec_instance = DeprecationSpec1()
          set_foo = lambda: setattr(spec_instance, "foo", 1)
          with pytest.raises(nib.TraitError):
              set_foo()
          assert len(w) == 0, "no warnings, just errors"
  
      with warnings.catch_warnings(record=True) as w:
          warnings.filterwarnings("always", "", UserWarning)
  
          class DeprecationSpec2(nib.TraitedSpec):
              foo = nib.traits.Int(deprecated="100", new_name="bar")
  
          spec_instance = DeprecationSpec2()
          set_foo = lambda: setattr(spec_instance, "foo", 1)
          with pytest.raises(nib.TraitError):
              set_foo()
          assert len(w) == 0, "no warnings, just errors"
  
      with warnings.catch_warnings(record=True) as w:
          warnings.filterwarnings("always", "", UserWarning)
  
          class DeprecationSpec3(nib.TraitedSpec):
              foo = nib.traits.Int(deprecated="1000", new_name="bar")
              bar = nib.traits.Int()
  
          spec_instance = DeprecationSpec3()
          not_raised = True
          try:
              spec_instance.foo = 1
          except nib.TraitError:
              not_raised = False
          assert not_raised
          assert (
              len(w) == 1
          ), f"deprecated warning 1 {[str(w1) for w1 in w]}"
  
      with warnings.catch_warnings(record=True) as w:
          warnings.filterwarnings("always", "", UserWarning)
  
          class DeprecationSpec3(nib.TraitedSpec):
              foo = nib.traits.Int(deprecated="1000", new_name="bar")
              bar = nib.traits.Int()
  
          spec_instance = DeprecationSpec3()
          not_raised = True
          try:
              spec_instance.foo = 1
          except nib.TraitError:
              not_raised = False
          assert not_raised
          assert spec_instance.foo == Undefined
          assert spec_instance.bar == 1
          assert (
              len(w) == 1
          ), f"deprecated warning 2 {[str(w1) for w1 in w]}"
  
imports: import os
  import warnings
  import pytest
  from ....utils.filemanip import split_filename
  from ...None import base
  from ...base import traits, Undefined
  from ....interfaces import fsl
  from ...utility.wrappers import Function
  from ....pipeline import Node
  from ..specs import get_filecopy_info
label_desc: Use image node_id 7 for calling a global function with example usage: test_deprecation() without return types