diff --git a/CAL/CalibrationCommon/test/t_holography_dataset_class.py b/CAL/CalibrationCommon/test/t_holography_dataset_class.py index b7bcc5f84a5595a0ceb5470a03ddc6575956eed0..7683fcf20b73add2410c2bf78999b9ea8b543d88 100755 --- a/CAL/CalibrationCommon/test/t_holography_dataset_class.py +++ b/CAL/CalibrationCommon/test/t_holography_dataset_class.py @@ -12,12 +12,21 @@ path_to_test_data = '/home/thomas/workspace.astron/data/holography' class TestHolographyDatasetClass(unittest.TestCase): - new_test_data_file = None + hdf5_data_file = None + holography_dataset_test_two = None - def tearDown(self): - if self.new_test_data_file is not None: - os.unlink(self.new_test_data_file) + @classmethod + def setUpClass(cls): + # Create an empty temporary data file + (fd, cls.hdf5_data_file) = tempfile.mkstemp(suffix = ".hdf5") + os.close(fd) + @classmethod + def tearDownClass(cls): + if cls.hdf5_data_file is not None: + print("**** %s " % (cls.hdf5_data_file)) +# os.unlink(cls.hdf5_data_file) + # def test_one(self): # holist = HolographyObservation.list_observations_in_path(path_to_test_data) # hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data) @@ -36,22 +45,19 @@ class TestHolographyDatasetClass(unittest.TestCase): for hbsf in hbsflist: hbsf.read_file() ho_per_ms = [(hbsf, ho) for hbsf, ho in zip(hbsflist, holist)] - - holography_dataset = HolographyDataset() - - holography_dataset.load_from_beam_specification_and_ms('CS013HBA0', ho_per_ms) - # Create an empty temporary data file - (fd, self.new_test_data_file) = tempfile.mkstemp(suffix = ".hdf5") - print "**** %s " % (self.new_test_data_file) - os.close(fd) + self.holography_dataset_test_two = HolographyDataset() + self.holography_dataset_test_two.load_from_beam_specification_and_ms( + 'CS013HBA0', ho_per_ms) + # Now store the MS data in an HDF5 file. - holography_dataset.store_to_file(self.new_test_data_file) + self.holography_dataset_test_two.store_to_file(self.hdf5_data_file) -# def test_three(self): -# # Read the MS data from an HDF5 file. -# holography_dataset = HolographyDataset.load_from_file(self.new_test_data_file) -# print holography_dataset + def test_three(self): + # Read the MS data from an HDF5 file. + holography_dataset_test_three = HolographyDataset.load_from_file(self.hdf5_data_file) + print(holography_dataset_test_three) + self.assertEqual(holography_dataset_test_three, self.holography_dataset_test_two) if __name__ == '__main__':