code: def test_datatype(self):
      ehdr = self.header_class()
      codes = self.header_class._data_type_codes
      for code in codes.value_set():
          npt = codes.type[code]
          if npt is np.void:
              with pytest.raises(HeaderDataError):
                  ehdr.set_data_dtype(code)
              continue
          dt = codes.dtype[code]
          ehdr.set_data_dtype(npt)
          assert ehdr["datatype"] == code
          assert ehdr["bitpix"] == dt.itemsize * 8
          ehdr.set_data_dtype(code)
          assert ehdr["datatype"] == code
          ehdr.set_data_dtype(dt)
          assert ehdr["datatype"] == code
  
imports: import itertools
  import logging
  import os
  import pickle
  import re
  from io import BytesIO, StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..None import imageglobals
  from ..analyze import AnalyzeHeader, AnalyzeImage
  from ..arraywriters import WriterError
  from ..casting import sctypes_aliases
  from ..nifti1 import Nifti1Header
  from ..optpkg import optional_package
  from ..spatialimages import HeaderDataError, HeaderTypeError, supported_np_types
  from ..testing import assert_dt_equal, bytesio_filemap, bytesio_round_trip, data_path, suppress_warnings
  from ..tmpdirs import InTemporaryDirectory
  from .None import test_spatialimages
  from .None import test_wrapstruct
label_desc: Use image node_id 16 for calling the TestAnalyzeHeader obj's underlying member method code with example usage: obj.test_datatype() without return types