old_contents: __author__ = "John Kirkham <kirkhamj@janelia.hhmi.org>"
  __date__ = "$Mar 30, 2015 08:25:33 EDT$"
  
  
  
new_contents: __author__ = "John Kirkham <kirkhamj@janelia.hhmi.org>"
  __date__ = "$Mar 30, 2015 08:25:33 EDT$"
  
  
  import collections
  import itertools
  import json
  import os
  import os.path
  import shutil
  import tempfile
  
  import numpy
  import h5py
  
  import vigra
  import vigra.impex
  
  import nanshe.nanshe.additional_generators
  import nanshe.nanshe.expanded_numpy
  
  import nanshe.nanshe.tiff_file_format
  import nanshe.nanshe.nanshe_converter
  
  
  class TestNansheConverter(object):
      def setup(self):
          self.temp_dir = ""
          self.filedata = collections.OrderedDict()
          self.data = None
  
          self.data = numpy.random.random_integers(0, 255, (1000, 1, 102, 101, 1)).astype(numpy.uint8)
  
          self.temp_dir = tempfile.mkdtemp()
          for i, i_str, (a_b, a_e) in nanshe.nanshe.additional_generators.filled_stringify_enumerate(
                                          itertools.izip(
                                                  *nanshe.nanshe.additional_generators.lagged_generators(
                                                      xrange(0, self.data.shape[0] + 100 - 1, 100)
                                                  )
                                          )
                                      ):
              each_filename = os.path.join(self.temp_dir, "test_tiff_" + str(i) + ".tif")
              each_data = self.data[a_b:a_e]
  
              self.filedata[each_filename] = each_data
  
              vigra.impex.writeVolume(nanshe.nanshe.expanded_numpy.tagging_reorder_array(each_data, to_axis_order="czyxt")[0, 0],
                                      os.path.join(self.temp_dir, "test_tiff_" + str(i) + ".tif"), "")
  
      def test_main(self):
          params = {
              "axis" : 0,
              "channel" : 0,
              "z_index" : 0,
              "pages_to_channel" : 1
          }
  
          config_filename = os.path.join(self.temp_dir, "config.json")
  
          hdf5_filename = os.path.join(self.temp_dir, "test.h5")
          hdf5_filepath = hdf5_filename + "/data"
  
          with open(config_filename, "w") as fid:
              json.dump(params, fid)
              fid.write("\n")
  
          main_args = ["./nanshe_converter.py"] + ["tiff"] + [config_filename] + self.filedata.keys() + [hdf5_filepath]
  
          assert (nanshe.nanshe.nanshe_converter.main(*main_args) == 0)
  
          assert os.path.exists(hdf5_filename)
  
          data = None
          with h5py.File(hdf5_filename, "r") as hdf5_handle:
              data = hdf5_handle["data"].value
  
          self_data_h5 = nanshe.nanshe.expanded_numpy.tagging_reorder_array(self.data, to_axis_order="cztyx")[0, 0]
  
          assert (data == self_data_h5).all()
  
          os.remove(hdf5_filename)
  
      def teardown(self):
          shutil.rmtree(self.temp_dir)
  
          self.temp_dir = ""
          self.filedata = collections.OrderedDict()
          self.data = None
  
subject: Add test for `nanshe_converter.main` separately from `tests/tiff_file_format.py`.