def test_convert_files(self): numarray_file_path = os.path.join(self.test_data_path, 'numarray_inputs', 'do_not_change_me.sometext') numpy_file_path = os.path.join(self.test_data_path, 'numpy_inputs', 'do_not_change_me.sometext') output_directory = self.temp_dir convert = ConvertNumarrayCacheToNumpyCache() convert.convert_file(os.path.join(self.test_data_path, 'numarray_inputs'), 'do_not_change_me.sometext', output_directory) self.assert_(os.path.exists(os.path.join(output_directory, 'do_not_change_me.sometext'))) endian = file_flt_storage.storage_file(None)._get_native_endian_file_extension_character() convert.convert_file(os.path.join(self.test_data_path, 'numarray_inputs'), 'f.Int32', output_directory) self.assert_(os.path.exists(os.path.join(output_directory, 'f.%si4' % endian))) convert.convert_file(os.path.join(self.test_data_path, 'numarray_inputs'), 'd.Float32', output_directory) self.assert_(os.path.exists(os.path.join(output_directory, 'd.%sf4' % endian))) convert.convert_file(os.path.join(self.test_data_path, 'numarray_inputs'), 'c.txt', output_directory) self.assert_(os.path.exists(os.path.join(output_directory, 'c.iS7'))) # Does the file contain the expected data? f = open(os.path.join(output_directory, 'c.iS7'), 'rb') actual = f.read() f.close() f = open(os.path.join(self.test_data_path, 'numpy_inputs', 'c.iS7'), 'rb') expected = f.read() f.close() self.assertEqual(expected, actual)
def test_convert_files(self): numarray_file_path = os.path.join(self.test_data_path, 'numarray_inputs', 'do_not_change_me.sometext') numpy_file_path = os.path.join(self.test_data_path, 'numpy_inputs', 'do_not_change_me.sometext') output_directory = self.temp_dir convert = ConvertNumarrayCacheToNumpyCache() convert.convert_file( os.path.join(self.test_data_path, 'numarray_inputs'), 'do_not_change_me.sometext', output_directory) self.assert_( os.path.exists( os.path.join(output_directory, 'do_not_change_me.sometext'))) endian = file_flt_storage.storage_file( None)._get_native_endian_file_extension_character() convert.convert_file( os.path.join(self.test_data_path, 'numarray_inputs'), 'f.Int32', output_directory) self.assert_( os.path.exists(os.path.join(output_directory, 'f.%si4' % endian))) convert.convert_file( os.path.join(self.test_data_path, 'numarray_inputs'), 'd.Float32', output_directory) self.assert_( os.path.exists(os.path.join(output_directory, 'd.%sf4' % endian))) convert.convert_file( os.path.join(self.test_data_path, 'numarray_inputs'), 'c.txt', output_directory) self.assert_(os.path.exists(os.path.join(output_directory, 'c.iS7'))) # Does the file contain the expected data? f = open(os.path.join(output_directory, 'c.iS7'), 'rb') actual = f.read() f.close() f = open(os.path.join(self.test_data_path, 'numpy_inputs', 'c.iS7'), 'rb') expected = f.read() f.close() self.assertEqual(expected, actual)