class_docstr: Test fake binary header defined at top of module
class_docstr_tok: ["Test","fake","binary","header","defined","at","top","of","module"]
code: def test_logger_error(self):
      # Check that we can reset the logger and error level
      # This is again specific to this pretend header
      HC = self.header_class
      hdr = HC()
      # Make a new logger
      str_io = StringIO()
      logger = logging.getLogger("test.logger")
      logger.setLevel(20)
      logger.addHandler(logging.StreamHandler(str_io))
      # Prepare something that needs fixing
      hdr["a_str"] = "Fullness"  # severity 20
      log_cache = imageglobals.logger, imageglobals.error_level
      try:
          # Check log message appears in new logger
          imageglobals.logger = logger
          hdr.copy().check_fix()
          assert (
              str_io.getvalue()
              == "a_str should be lower case; set a_str to lower case\n"
          )
          # Check that error_level in fact causes error to be raised
          imageglobals.error_level = 20
          with pytest.raises(HeaderDataError):
              hdr.copy().check_fix()
      finally:
          imageglobals.logger, imageglobals.error_level = log_cache
  
imports: import logging
  from io import BytesIO, StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..None import imageglobals
  from ..batteryrunners import Report
  from ..casting import sctypes
  from ..spatialimages import HeaderDataError
  from ..volumeutils import Recoder, native_code, swapped_code
  from ..wrapstruct import LabeledWrapStruct, WrapStruct, WrapStructError
label_desc: Use image node_id 9 for calling the TestMyWrapStruct obj's underlying member method code with example usage: obj.test_logger_error() without return types