def testGzip(self):
        workdir = os.path.join(self.workDir, "archive")
        util.mkdirChain(workdir)
        archivePath = os.path.join(workdir, "file")
        f = file(archivePath, "w+")
        content = "0123456789abcdef"
        for i in range(1024):
            f.write(content)
        f.close()
        cmd = [ 'gzip', archivePath ]
        subprocess.call(cmd)
        archivePath += '.gz'
        a = Archive(archivePath, self._log)
        a.extract()
        self.failUnlessEqual(sorted(x.name for x in a),
            [ 'file' ])
        self.failUnlessEqual(sorted(x.size for x in a),
            [ 16384 ])
        member = list(a)[0]
        fobj = a.extractfile(member)

        self.failUnlessEqual(fobj.size, 16384)
        self.failUnlessEqual(fobj.read(16), "0123456789abcdef")
        self.failUnlessEqual(fobj.tell(), 16)
        fobj.seek(1)
        self.failUnlessEqual(fobj.tell(), 1)
        fobj.close()
 def _runTests(self, archivePath):
     a = Archive(archivePath, self._log)
     a.extract()
     self.failUnlessEqual(sorted(x.name for x in a),
         [
             'subdir/foo.ovf', 'subdir/subsubdir1/a/b/c/deep.data',
             'subdir/subsubdir1/bar1.data',
             'subdir/subsubdir2/bar1.data', 'subdir/subsubdir2/bar2.data'])
     # Get one of the files
     member = [ x for x in a if x.name.endswith('deep.data') ][0]
     # Make sure we have a size member
     self.failUnlessEqual(member.size, 4)
     self.failUnlessEqual(member.name, 'subdir/subsubdir1/a/b/c/deep.data')
     # Make sure we can extract data
     fobj = a.extractfile(member)
     self.failUnlessEqual(fobj.name, 'subdir/subsubdir1/a/b/c/deep.data')
     self.failUnlessEqual(fobj.size, 4)
     self.failUnlessEqual(fobj.read(2), "de")
     self.failUnlessEqual(fobj.read(2), "ep")
     fobj = a.extractfile(member)
     self.failUnlessEqual(fobj.size, 4)
     self.failUnlessEqual(fobj.read(), "deep")
     self.failUnlessEqual(fobj.tell(), 4)
     fobj.seek(1)
     self.failUnlessEqual(fobj.tell(), 1)
     fobj.close()