code: def test_warn_error():
      # Check warning error context manager
      n_warns = len(warnings.filters)
      with error_warnings():
          with pytest.raises(UserWarning):
              warnings.warn("A test")
      with error_warnings() as w:  # w not used for anything
          with pytest.raises(UserWarning):
              warnings.warn("A test")
      assert n_warns == len(warnings.filters)
      # Check other errors are propagated
  
      def f():
          with error_warnings():
              raise ValueError("An error")
  
      with pytest.raises(ValueError):
          f()
  
file_path: nibabel/nibabel/tests/test_testing.py
imports: import os
  import sys
  import warnings
  import numpy
  import pytest
  from ..casting import sctypes
  from ..testing import assert_allclose_safely, assert_re_in, clear_and_catch_warnings, data_path, error_warnings, get_fresh_mod, get_test_data, suppress_warnings
label_desc: Use image node_id 5 for calling a global function with example usage: test_warn_error() without return types