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_bytes(self):
      # Test get of bytes
      hdr1 = self.header_class()
      bb = hdr1.binaryblock
      hdr2 = self.header_class(hdr1.binaryblock)
      assert hdr1 == hdr2
      assert hdr1.binaryblock == hdr2.binaryblock
      # Do a set into the header, and try again.  The specifics of 'setting
      # something' will depend on the nature of the bytes object
      self._set_something_into_hdr(hdr1)
      hdr2 = self.header_class(hdr1.binaryblock)
      assert hdr1 == hdr2
      assert hdr1.binaryblock == hdr2.binaryblock
      # Short and long binaryblocks give errors
      # (here set through init)
      with pytest.raises(WrapStructError):
          self.header_class(bb[:-1])
      with pytest.raises(WrapStructError):
          self.header_class(bb + b"\x00")
      # Checking set to true by default, and prevents nonsense being
      # set into the header.
      bb_bad = self.get_bad_bb()
      if bb_bad is None:
          return
      with imageglobals.LoggingOutputSuppressor():
          with pytest.raises(HeaderDataError):
              self.header_class(bb_bad)
      # now slips past without check
      _ = self.header_class(bb_bad, check=False)
  
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 13 for calling the _TestWrapStructBase obj's underlying member method code with example usage: obj.test_bytes() without return types