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_to_from_fileobj(self):
      # Successful write using write_to
      hdr = self.header_class()
      str_io = BytesIO()
      hdr.write_to(str_io)
      str_io.seek(0)
      hdr2 = self.header_class.from_fileobj(str_io)
      assert hdr2.endianness == native_code
      assert hdr2.binaryblock == hdr.binaryblock
  
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 5 for calling the _TestWrapStructBase obj's underlying member method code with example usage: obj.test_to_from_fileobj() without return types