class_docstr: Class implements base tests for binary headers
  
  It serves as a base class for other binary header tests
class_docstr_tok: ["Class","implements","base","tests","for","binary","headers","It","serves","as","a","base","class","for","other","binary","header","tests"]
code: def test_mappingness(self):
      hdr = self.header_class()
      with pytest.raises(ValueError):
          hdr["nonexistent key"] = 0.1
      hdr_dt = hdr.structarr.dtype
      keys = hdr.keys()
      assert keys == list(hdr)
      vals = hdr.values()
      assert len(vals) == len(keys)
      assert keys == list(hdr_dt.names)
      for key, val in hdr.items():
          assert_array_equal(hdr[key], val)
      # verify that .get operates as destined
      assert hdr.get("nonexistent key") is None
      assert hdr.get("nonexistent key", "default") == "default"
      assert hdr.get(keys[0]) == vals[0]
      assert hdr.get(keys[0], "default") == vals[0]
  
      # make sure .get returns values which evaluate to False. We have to
      # use a different falsy value depending on the data type of the first
      # header field.
      falsyval = 0 if np.issubdtype(hdr_dt[0], np.number) else b""
  
      hdr[keys[0]] = falsyval
      assert hdr[keys[0]] == falsyval
      assert hdr.get(keys[0]) == falsyval
      assert hdr.get(keys[0], -1) == falsyval
  
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 6 for calling the _TestWrapStructBase obj's underlying member method code with example usage: obj.test_mappingness() without return types