Beispiel #1
0
	def testVirtualFiles(self):
		"""Testing virtual files"""
		tempout = self.conn.open("testfiles/tempout", "w")
		assert isinstance(tempout, VirtualFile)
		regfilefp = open(self.regfilename, "r")
		rpath.copyfileobj(regfilefp, tempout)
		tempout.close()
		regfilefp.close()
		tempoutlocal = open("testfiles/tempout", "r")
		regfilefp = open(self.regfilename, "r")
		assert rpath.cmpfileobj(regfilefp, tempoutlocal)
		tempoutlocal.close()
		regfilefp.close()
		os.unlink("testfiles/tempout")

		assert rpath.cmpfileobj(self.conn.open(self.regfilename, "r"),
								open(self.regfilename, "r"))
Beispiel #2
0
    def testVirtualFiles(self):
        """Testing virtual files"""
        # generate file name for temporary file
        temp_file = os.path.join(abs_test_dir, b"tempout")

        tempout = self.conn.open(temp_file, "wb")
        assert isinstance(tempout, VirtualFile)
        regfilefp = open(regfilename, "rb")
        rpath.copyfileobj(regfilefp, tempout)
        tempout.close()
        regfilefp.close()
        tempoutlocal = open(temp_file, "rb")
        regfilefp = open(regfilename, "rb")
        assert rpath._cmp_file_obj(regfilefp, tempoutlocal)
        tempoutlocal.close()
        regfilefp.close()
        os.unlink(temp_file)

        with open(regfilename, "rb") as localfh:
            assert rpath._cmp_file_obj(self.conn.open(regfilename, "rb"), localfh)
Beispiel #3
0
def write_patched_fp(basis_fp, delta_fp, out_fp):
    """Write patched file to out_fp given input fps.  Closes input files"""
    rpath.copyfileobj(librsync.PatchedFile(basis_fp, delta_fp), out_fp)
    basis_fp.close()
    delta_fp.close()