def test_resulting_file(self): """Make sure GZip changes are pushed through to actual file.""" import tempfile import os (fd, fn) = tempfile.mkstemp() os.close(fd) try: f = open(fn, "w") f.write("hello world!") f.close() f = GZip(open(fn, "r+")) f.read(6) f.seek(-6, 1) f.write(gz_compress("hello Australia!")) f.close() self.assertEquals(open(fn).read(), "hello Australia!") finally: os.unlink(fn)
def makeFile(self, contents, mode): s = StringIO(gz_decompress(contents)) f = GZip(s, mode) f.getvalue = def_getvalue_maybe_buffered(f, s, gz_compress) return f