Exemplo n.º 1
0
 def compare(self, in_, out_):
     """Read file1, write file2, then compare. Return value as for files_identical"""
     dataset = read_file(in_)
     write_file(out_, dataset)
     same, pos = files_identical(in_, out_)
     self.assert_(same, "Files are not identical - first difference at 0x%x" % pos)
     if os.path.exists(out_):
         os.remove(out_)  # get rid of the file
Exemplo n.º 2
0
 def compare_write(self, hex_std, file_ds):
     """Write file and compare with expected byte string
     
     :arg hex_std: the bytes which should be written, as space separated hex 
     :arg file_ds: a FileDataset instance containing the dataset to write
     """
     out_filename = "scratch.dcm"
     write_file(out_filename, file_ds)
     std = hex2bytes(hex_std)
     bytes_written = open(out_filename,'rb').read()
     # print "std    :", bytes2hex(std)
     # print "written:", bytes2hex(bytes_written)
     same, pos = bytes_identical(std, bytes_written)
     self.assert_(same, "Writing from scratch not expected result - first difference at 0x%x" % pos)
     if os.path.exists(out_filename):
         os.remove(out_filename)  # get rid of the file