예제 #1
0
파일: test_copy.py 프로젝트: drussel/imp
 def _copy_to(self, last_frame, suffix):
     nm= RMF._get_test_input_file_path("sink.rmf")
     onm= RMF._get_temporary_file_path("sink_out."+suffix)
     print nm, onm
     f= RMF.open_rmf_file_read_only(nm)
     of= RMF.create_rmf_file(onm)
     RMF.copy_structure(f, of)
     fr= of.get_root_frame()
     for i in range(-1, last_frame+1):
         f.set_current_frame(i)
         print fr.get_id(), f.get_current_frame().get_id()
         RMF.copy_frame(f, of)
         fr= fr.add_child(str(i), RMF.FRAME)
     print "deling"
     del fr
     del of
     print "reopening"
     of= RMF.open_rmf_file_read_only(onm)
     self.assert_(RMF.get_equal_structure(f, of, True))
     for i in range(-1, last_frame+1):
         print i
         f.set_current_frame(i)
         of.set_current_frame(i)
         if suffix != "rmft":
             # going through a text format perturbs values
             self.assert_(RMF.get_equal_frame(f, of, True))
예제 #2
0
    def test_perturbed(self):
        """Test copying an rmf file"""
        nm= self.get_input_file_name("sink.rmf")
        onm= self.get_tmp_file_name("sink_out.rmf")
        f= RMF.open_rmf_file_read_only(nm)
        of= RMF.create_rmf_file(onm)
        RMF.copy_structure(f, of)
        nf= f.get_number_of_frames()
        for i in range(0, nf):
            RMF.copy_frame(f, of, i, i)

        self.assert_(RMF.get_equal_structure(f, of, True))
        for i in range(0, nf):
            self.assert_(RMF.get_equal_frame(f, of, i, i, True))
예제 #3
0
    def test_perturbed(self):
        """Test copying a rmf file to a prmf file"""
        nm = self.get_input_file_name("sink.rmf")
        onm = self.get_tmp_file_name("sink_out.prmf")
        f = RMF.open_rmf_file_read_only(nm)
        try:
            of = RMF.create_rmf_file(onm)
        except:
            self.skipTest("No google protobuf support")
        RMF.copy_structure(f, of)
        self.assert_(RMF.get_equal_structure(f, of, True))
        nf = f.get_number_of_frames()
        for i in range(0, nf):
            RMF.copy_frame(f, of, i, i)

        for i in range(0, nf):
            self.assert_(RMF.get_equal_frame(f, of, i, i, True))
예제 #4
0
 def test_simple(self):
     """Test copying a simple rmf file to prmf"""
     nm = self.get_input_file_name("simple.rmf")
     onm = self.get_tmp_file_name("simple.prmf")
     f = RMF.open_rmf_file_read_only(nm)
     try:
         of = RMF.create_rmf_file(onm)
     except:
         self.skipTest("No google protobuf support")
     RMF.copy_structure(f, of)
     # RMF.show_hierarchy(of.get_root_node())
     of.flush()
     RMF.show_hierarchy(of.get_root_node())
     self.assert_(RMF.get_equal_structure(f, of, True))
     nf = f.get_number_of_frames()
     for i in range(0, nf):
         RMF.copy_frame(f, of, i, i)
     for i in range(0, nf):
         self.assert_(RMF.get_equal_frame(f, of, i, i, True))